Can't get Intern to run Node.js Module -
i trying test intern see if fit testing framework. trying test following code in intern.
var helloworld; helloworld = (function () { function helloworld (name) { this.name = name || "n/a"; } helloworld.prototype.printhello = function() { console.log('hello, ' + this.name); }; helloworld.prototype.changename = function(name) { if (name === null || name === undefined) { throw new error('name required'); } this.name = name; }; return helloworld; })(); exports = module.exports = helloworld;
the file located in 'js-test-projects/node/lib/helloworld.js' , intern located @ 'js-test-projects/intern'. using 1.0.0 branch of intern. whenever try include file , run test don't output after "defaulting console reporter". here test file.
define([ 'intern!tdd', 'intern/chai!assert', 'dojo/node!../lib/helloworld' ], function (tdd, assert, helloworld) { console.log(helloworld); });
1. assuming following directory structure (based on question):
js-test-projects/ node/ lib/ helloworld.js - `helloworld` node module tests/ helloworld.js - tests `helloworld` intern.js - intern configuration file intern/
2. intern configuration file should contain info on node
package , suites run:
// ... // configuration options module loader loader: { // packages should registered loader in each testing environment packages: [ 'node' ] }, // non-functional test suite(s) run suites: [ 'node/tests/helloworld' ] // ...
3. test file should load helloworld
using intern's version of dojo, this:
define([ 'intern!tdd', 'intern/chai!assert', 'intern/dojo/node!./node/lib/helloworld.js' ], function (tdd, assert, helloworld) { console.log(helloworld); });
note: don't have use intern's version of dojo load helloworld
node module in amd test, convenient way so. if have other amd plugin node-requires node module, that's fine.
4. finally, run tests in node.js environment, use intern's client.js
node runner issuing following command within intern
directory:
node client.js config=node/tests/intern
Comments
Post a Comment