Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am new to Intern and struggling with trying to get a simple test to run in my environment. I was able to get the tutorial test to run but I've tried to set up a test where the test file is located inside my app directory hierarchy. The module being tested is located here:

sandbox/web/libs/ev/grids/FilterGrid.js

The test file is located here:

sandbox/web/libs/ev/tests/FilterGrid.js

My intern config file is located here:

sandbox/tests/intern.js

My loader and suites objects looks like this:

loader: {
    packages: [
        { name: 'dojo', location: 'web/libs/dojo' },
        { name: 'dijit', location: 'web/libs/dijit },
        { name: 'dgrid', location: 'web/libs/dgrid' },
        { name: 'put-selector', location: 'web/libs/put-selector' },
        { name: 'xstyle', location: 'web/libs/xstyle' },
        { name: 'ev', location: 'web/libs/ev' }
    ]
},
suites: ['ev/tests/FilterGrid'],

When the loader tries to load this, I get:

Defaulting to "console" reporter
ReferenceError: document is not defined
    at /home/bholm/Projects/src/sandbox/web/libs/dojo/selector/_loader.js:5:15
    at execModule (/home/bholm/Projects/src/sandbox/node_modules/intern/node_module
        /dojo/dojo.js:512:54)
    at /home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:579:7
    at guardCheckComplete (/home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:563:4)
    at checkComplete (/home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:571:27)
    at onLoadCallback (/home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:653:7)
    at /home/bholm/Projects/src/sandbox/node_modules/intern/node_modules/dojo/dojo.js:746:5
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

Does the unit tests using Intern need a DOM document defined?? I also notice that Intern lists dojo2_core as it's dependency. So it's using unreleased code?

Any help with this would be appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
716 views
Welcome To Ask or Share your Answers For Others

1 Answer

It looks like you’re trying to load some code using the Node.js client that requires a browser environment. This won’t work. You should only load the ev/tests/FilterGrid test suite in a browser. You can do this by modifying your Intern configuration file to look something like this:

define([ 'intern/node_modules/dojo/has' ], function (has) {
  var suites = [];

  if (has('host-browser')) {
    suites.push('ev/tests/FilterGrid');
  }

  return {
    // ...your existing configuration...
    suites: suites,
    // ...
  };
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...