https://github.com/jquery/qunit
$ npm i qunithttp://api.qunitjs.com
// Separate tests into modules. // Use `QUnit` namespace, because `module` is reserved for node. QUnitRead 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 = ; // 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) globalCoverage: true // log currently testing code file testing: true // run test coverage tool coverage: false // define dependencies, which are required then before code deps: null // define namespace your code will be attached to on global['your namespace'] namespace: null // max amount of ms child can be blocked, after that we assume running an infinite loop maxBlockDuration: 2000// change any option for all tests globally testrunneroptionsoptionName = value; // or use setup function testrunner; // one code and tests file testrunner; // require code into a namespace object, rather than globally testrunner; // one code and multiple tests file testrunner; // array of code and test files testrunner; // using testrunner callback testrunner; // specify dependency testrunner; // dependencies can be modules or files testrunner; // dependencies can required into a namespace object testrunner; // specify multiple dependencies testrunner;QUnit API and code which have to be tested are already loaded and attached to the global context.
Some tests examples
; QUnit; ; ; QUnit; ; QUnit; ; ;;$ 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.