How to add 'has' module when executing DOH tests?

75 Views Asked by At

I'm building a suite of Dojo/DOH unit tests that are executed by using the built-in browser runner. In addition to the unit tests, I'm building a facility to create mocks for the unit tests, but it requires the Dojo 'undef' API (dojo-undef-api). During the boot process, Dojo will look at the hasCache to see if the dojo-undef-api has been registered, and if it has, it will tack on a undef method to the global require object to allow modules to be undefined.

Since I'm using the built-in browser runner to execute my tests, I'm curious if there is any way to include or register the dojo-undef-api. Really, the only means I have in terms of configuration is the URL and URL parameters. Any help would be appreciated.

1

There are 1 best solutions below

0
On

How are you including dojo for your tests? You should be able to configure any options you need there.

If that is not possible for some reason, I'm not completely sure that the dojo-undef-api can be configured this way, but require can take a configuration object as its first argument:

If a configuration object is provided, it is passed to the configuration API as described in Configuration. Next, the dependencies listed in dependencies (if any) are resolved. Finally, callback (if any) is executed with the resolved dependencies passed in as arguments.

The reason I'm not 100% sure that it can be done that way are the caveats with the has API listed here in the note underneath the example of using a configuration object with require.

The document that all the links in my answer comes from goes into a lot more detail and may contain the answers that you need.

I would also check out _parseURLargs.js to see the defaults that the DOH runner uses.