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:

  1. since intern’s loader sets of same rules, can load intern/node_modules/dojo/has , run has.add('dojo-has-api', true) before else tries load dojo/has module. should cause dojo use has.js implementation intern’s loader (and adopt rules has set, includes host-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…     }; }); 
  2. before loading modules call has('host-node'), load dojo/has , intern/node_modules/dojo/has , call dojohas.add('host-node', internhas('host-node')) (or guess can hard code :)). require loader plugin used in place of suites 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 change suites: [ '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

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -