Intern Testing Non Amd Code
// Intern - Functional Testing - Testing non-AMD code:
CommonJS code, including Node.js built-in libraries, can be loaded (as an AMD-
dependency from within Node.js) and used in functional testing, using the
dojo/node AMD plugin that comes with Intern:
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!path'
], function (registerSuite, assert, path) {
registerSuite({
name: 'path',
'basic tests': function () {
path.join('a', 'b');
// ...
}
});
});
In the above code, we use the 'path' library from NodeJS.
If we are attempting to test non-AMD code that is split across multiple
JavaScript files which must be loaded in a specific order, use the 'intern/order'
plugin instead of specifying those files as a direct dependencies:
define([
'intern!object',
'intern/chai!assert',
'intern/order!../jquery.js',
'intern/order!../plugin.jquery.js'
], function (registerSuite, assert) {
registerSuite({
name: 'plugin.jquery.js',
'basic tests': function () {
jQuery('<div>').plugin();
// ...
}
});
});
page revision: 0, last edited: 10 Feb 2017 23:47