How to run intern to test a dojo application running with node.js ? -
i'm trying use intern test dojo application running under node.js
my intern.js configuration file like:
define({ loader: { packages: [ { name: 'elenajs', location: 'lib' }, { name: 'tests', location: 'tests' } ], map: { 'elenajs': { dojo: 'node_modules/dojo' }, 'tests': { dojo: 'node_modules/dojo' } } }, suites: [ 'tests/all' ]});
when try run test node node_modules/intern/client.js config=tests/intern
, error: error: node plugin failed load because environment not node.js
.
normally have configured dojo
dojoconfig = { ... hascache: { "host-node": 1, // ensure "force" loader node.js mode "dom": 0 // ensure none of code assumes have dom }, ... };
how can solve intern?
the issue experiencing caused fact there code in dojo relies on has-rules being set dojo loader, doesn’t happen because dojo loader isn’t in use. there couple of potential workarounds:
since intern’s loader sets of same rules, can load
intern/node_modules/dojo/has
, runhas.add('dojo-has-api', true)
before else tries loaddojo/has
module. should cause dojo usehas.js
implementation intern’s loader (and adopt rules has set, includeshost-node
). best place going intern configuration file, end being this:define([ 'intern/dojo/has' ], function (has) { has.add('dojo-has-api', true); return { // existing intern configuration object… }; });
before loading modules call
has('host-node')
, loaddojo/has
,intern/node_modules/dojo/has
, calldojohas.add('host-node', internhas('host-node'))
(or guess can hard code :)). require loader plugin used in place ofsuites
array:// tests/preload.js define({ load: function (id, require, callback) { require([ 'dojo/has' ], function (has) { has.add('host-node', true); require(id.split(/\s*,\s*/), callback); } } });
and
suites
changesuites: [ 'tests/preload!tests/all,tests/foo,tests/bar' ]
.
any other has-rules dojo code relies on set dojo loader need set yourself. other rules dojo adds other parts of work correctly.
Comments
Post a Comment