Reputation: 509
I've written simple unit tests for our controller/Router.. but can't get them run by intern.. The Router module needs to load other modules, e.g. pace.js in this instance, and I needed to add it to intern's config file as a dependency in loader/packages... It then loads the Pace module ok, but the intern's runner fails with 'Reference Error: window is not defined'. Pace module needs to run in browser, but intern seems to be running it in Node context... I'm using the following command:
node node_modules/intern/client.js config=test/intern
I tried this answer, ie. taken out the Pace module from loader/packages, and added the testcase only if intern is in host-browser context.. but then intern skips my testcase, as it can't enter in the if(has) block... here is the code i added to intern.js:
var suites = [];
suites.push('test/unit/all');
if (has('host-browser')) {
suites.push('test/unit/app/controller/Router');
}
return {
// ...
suites: suites,
// ...
};
Intern seems to be switching its context to Node, how can I keep it in browser?
Upvotes: 1
Views: 673
Reputation: 3363
client.js
is Intern's node.js client, which runs tests under Node.js. To run tests in a browser, you either need to use client.html or run tests using runner.js and a WebDriver server such as Selenium.
Upvotes: 2