I installed qunit, using command:
npm install -g qunit
Then, I wrote a test program and named the file as firstTest.js. The contents of firstTest.js is:
module.exports = {
'should run test': function(t) {
t.printf("running test!\n");
t.done();
},
};
On executing command:
qunit firstTest.js
I got 'qunit' is not recognised as an internal or external command, operable program or batch file. What should I do ?
Okay, so first off, that is not how you write a QUnit test. You can read the documentation here, but essentially you need to write code that a browser can interpret, and
module.exports
is not a browser object, it's only in Node.Now, if you are using some other Node module that let's you write tests that way, cool! But if you are using the base
qunit
module you can't write tests that way. Here's how you can write that test in proper QUnit:Now you need to load that test file in an HTML file and open it in the browser:
Second, QUnit does not have a CLI executable program bundled with it. You will need to use another module to run that test from the command line. Something like the task runner Grunt combined with the grunt-contrib-qunit plugin.