Cannot run unit tests on modules with dependencies on dojo 1.x using the Intern -


we starting out getting unit tests running in intern on our dojo-based project.

what happens when intern tries load module under test's dependencies following error:

/<path/to/dev/folder>/app/node_modules/intern/node_modules/dojo/dojo.js:406                 match = mid.match(/^(.+?)\!(.*)$/);                            ^     typeerror: cannot read property 'match' of null @ getmodule (/<path/to/dev/folder>/app/node_modules/intern/node_modules/dojo/dojo.js:406:15) @ mix.amd.vendor (/<path/to/dev/folder>/app/node_modules/intern/node_modules/dojo/dojo.js:832:17) @ /<path/to/dev/folder>/app/src/simplebuilding/model/modelerror.js:10:1     @ exports.runinthiscontext (vm.js:74:17)     @ object.vm.runinthiscontext (/<path/to/dev/folder>/app/node_modules/intern/node_modules/istanbul/lib/hook.js:163:16)     @ /<path/to/dev/folder>/app/node_modules/intern/node_modules/dojo/dojo.js:762:8     @ fs.js:334:14     @ fsreqwrap.oncomplete (fs.js:95:15) 

here config file - started copying example one, , adding map section loader.

define({     proxyport: 9000,     proxyurl: 'http://localhost:9000/',     capabilities: {         'selenium-version': '2.41.0'     },     { browsername: 'chrome', version: '40', platform: [ 'os x' ] }     ],     maxconcurrency: 3,     tunnel: 'nulltunnel',     loader: {     // packages should registered loader in each testing environment     packages: [       { name: 'dojo', location: 'src/dojo' },       { name: 'dojox', location: 'src/dojox' },       { name: 'dijit', location: 'src/dijit' },       { name: 'app', location: 'src/app' },       { name: 'tests', location: 'tests' }     ],     map: {       '*': {         'dojo' : 'dojo'       },       app : {         'dojo' : 'dojo'       },       intern : {         'dojo' : 'node_modules/intern/node_modules/dojo'       },       'tests' : {         'dojo' : 'dojo'       }     }     },     suites: [ 'tests/model/modelerror' ],     functionalsuites: [ /* 'mypackage/tests/functional' */ ],     excludeinstrumentation: /^(?:tests|test\-explore|node_modules)\// }); 

the file under test has dependencies on dojo/_base/declare, dojo/_base/lang, , dojo/stateful, , it.

i created dummy class test there no dojo dependencies , runs fine.

i've tried switching loader local dojo 1.10.3 version have in our project, , throws entirely different errors not being able find intern (even if give package definition in config). errors this:

{ [error: enoent, no such file or directory '/<path/to/dev/folder>/app/node_modules/.bin/main.js']   errno: -2,   code: 'enoent',   path: '/<path/to/dev/folder>/app/node_modules/.bin/main.js',   syscall: 'open' } 

our project structure pretty straight-forward:

root |--src    |--dojo (dijit/dojox/dgrid/etc)    |--app |--tests    |--intern.js (config file) 

i've tried several variations besides changing loader, trying make sure base-path correct. i've tried running in node 0.10.36, , 0.12.2. every time debug node-inspector when gets load module file under test , mid null, , jumping stack trace looks fine, lost in vm.runinthiscontext() call, , mid disappears time getmodule() called.

any appreciated - thanks!

so figured out - had modules loading inside of our project used old style of define() function. had moved old define('my.module.namespace', ['deps'], function(deps){ ... }); replacing dot namespace module in first argument null. doing transitionary phase removing argument completely, hadn't ever finished transition. causing dojo2 loader think "id" of module null, , causing loader not find module id.

this silly mistake on our part, , modernize updated signature future-dojo-readiness.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -