The null module exports null
and is used when mapping modules to an
unsupported runtime.
$ volo add anchorjs/null
To map an unsupported module to the null
module, use the map
option when
configuring a
compatible AMD loader, such as RequireJS.
require.config({
packages: [
{ name: 'null', main: 'null' },
],
map: {
'*': {
'fs': 'null'
}
}
});
In the above example, any time the fs
module is require()
'd, the null
module will be substituted. This is particularly useful when using Node
modules in a browser context, via technologies such as JSMT.
Inside a module that uses the file system, support can be conditionally checked.
if (fs) {
// access the file system
} else {
// fallback behavior
}
When running in Node, the module has access to the file system. However, when running within a browser, the file system is not available and fallback behavior is executed.
To run tests in a browser, execute the Make target for the desired browser:
$ make test-chrome
$ make test-firefox
$ make test-safari
Headless tests can be executed directly from a terminal:
$ make test-phantomjs
Copyright (c) 2012-2013 Jared Hanson <http://jaredhanson.net/>