I'm trying to run a unit test using Dojo Intern. My project structure is similar to what I have below. The issue I'm getting is when I try to testing the widget in a stand-alone browser client, I get the following errors:
TypeError: undefined is not a function deps: "dojo/cldr/nls/gregorian"
TypeError: undefined is not a function deps: "dojo/cldr/nls/number"
and when I test the widget using in a stand-alone Node.js client, I get:
ReferenceError: document is not defined at C:/Repos/trunk/src/main/webapp/js/dojo/has.js:102:37 at execModule (C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:515:54) at C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:504:12 at Array.map (native) at execModule (C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:499:17) at C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:504:12 at Array.map (native) at execModule (C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:499:17) at C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:582:7 at guardCheckComplete (C:\Users\yolo\AppData\Roaming\npm\node_modules\intern\node_modules\dojo\dojo.js:566:4)
I'm not sure why these errors are generating. Is it because Intern can't load the other dependencies from the widget foo.js? Can someone please help give me pointers on how to resolve this issue?
Project structure:
/myProject
js/
app/
widgets/
foo.js
dijit/
dojo/
dojox/
tests/
functional/
unit/
widgets/
foo.js
all.js
intern.js
node_modules/
intern/
package.json
all.js
define([
'./unit/widgets/foo'
], function() {});
intern.js config:
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [{ browserName: 'chrome' }],
tunnel: 'NullTunnel',
useSauceConnect: false,
useLoader: {
'host-node': 'dojo/dojo',
'host-browser': 'node_modules/dojo/dojo.js'
},
loader: {
packages: [
{ name: 'main', location: 'js/app/widgets' },
{ name: 'dijit', location: 'js/dijit'},
{ name: 'dojo', location: 'js/dojo' },
{ name: 'dojox', location: 'js/dojox' }
]},
suites: [ 'tests/all' ],
excludeInstrumentation: /^(?:tests|node_modules)\//
});
js/app/widgets/foo.js
define(["dojo/_base/lang",
"dojo/date",
"dojo/date/locale",
"dojo/number",
"dojo/string",
"dojox/date/timezone"], function (lang, date, locale, number, string) { ... }
tests/unit/widgets/foo.js
define([
'intern!object',
'intern/chai!assert',
'main/foo'
], function (registerSuite, assert, main) { ... }