package
QUnit testing framework for nodejs (with multiple source files coverage hack)
npm install qunit-multi-coverageGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
http://github.com/jquery/qunit
$ npm i qunithttp://api.qunitjs.com// Separate tests into modules.
// Use `QUnit` namespace, because `module` is reserved for node.
QUnit.module(name, lifecycle)Read full cli api doc using "--help" or "-h":
$ qunit -h
$ qunit -c ./code.js -t ./tests.jsBy default, code and dependencies are added to the global scope. To specify requiring them into a namespace object, prefix the path or module name with the variable name to be used for the namespace object, followed by a colon:
$ qunit -c code:./code.js -d utils:utilmodule -t ./time.jsvar testrunner = require("qunit");
// Defaults:
{
// logging options
log: {
// log assertions overview
assertions: true,
// log expected and actual values for failed tests
errors: true,
// log tests overview
tests: true,
// log summary
summary: true,
// log global summary (all files)
globalSummary: true,
// log coverage
coverage: true,
// log global coverage (all files)
// change any option for all tests globally
testrunner.options.optionName = value;
// or use setup function
testrunner.setup({
log: {
summary: true
}
});
// one code and tests file
testrunner.run({
code: "/path/to/your/code.js",
tests: "/path/to/your/tests.js"
}, callback);
// require code into a namespace object, rather than globally
testrunner.run({
code: {path: "/path/to/your/code.js", namespace: "code"},
tests: "/path/to/your/tests.js"
}, callback);
// one code and multiple tests file
testrunner.run({
code:
QUnit API and code which have to be tested are already loaded and attached to the global context.
Some tests examples
test("a basic test example", function () {
ok(true, "this test is fine");
var value = "hello";
equal("hello", value, "We expect value to be hello");
});
QUnit.module("Module A");
test("first test within module", 1, function () {
ok(true, "a dummy");
});
test("second test within module", 2, function () {
ok(true, "dummy 1 of 2"
test("my async test with generators", function* () {
var data = yield asyncFn();
equal(data, {a: 1}, 'generators work');
});$ npm i
$ npm testCode coverage via Istanbul.
To utilize, install istanbul and set option coverage: true or give a path where to store report coverage: {dir: "coverage/path"} or pass --cov parameter in the shell.
To specify the format of coverage report pass reporters array to the coverage options: coverage: {reporters: ['lcov', 'json']} (default)
Coverage calculations based on code and tests passed to node-qunit.
Estimated unpacked size across 52 packages.
12.6 MB
Includes dependencies.
7 direct · 3 outdated
^3.0.6
4.6.0
1.10.0
2.4.1
^0.1.8
0.1.8
https://github.com/gotwarlost/istanbul/tarball/harmony
0.4.5
^0.3.0
0.3.11
^0.0.6
0.0.7
^1.6.0
1.13.8