JavaScript native QUnit runner with code coverage and multiple extensions


Simple JS unit testing framework similar to QUnit.

  1. Make sure QUnit tests work with istanbul JS coverage tool
  2. Experiment with JS unit testing by writing a framework from scratch.

gt requires nodejs and a few modules to run. Assuming you wrote a few qunit tests in tests.js:

npm install -g gt
gt tests.js

some of the options (-h for all):
    -l <debug level> 0 = debug, 1 = default, 2 = warnings, 3 = errors
    -r <report level> 0 = all (default), 1 = failed tests only

A simple example is in examples subfolder

Unit tests follow QUnit approach:

gt.module("Basic tests");
gt.test("get N '='", function () {
    gt.ok(typeof getLines === "function", "getLines is a function");
    gt.equal(getLines(0), "", "0 character");
    gt.equal(getLines(1), "=", "1 character");

Creates unit test report (stdout only) and JS code coverage (stdout plus Lines of Code + HTML in folder cover)

gt ./examples/basic/tests ./examples/basic/exceptionTests

Sample unit test output image

Sample JS coverage output image

You can write your unit tests using coffeescript, which allows very concise code. So far, the code coverage does not include the unit test files themselves, they will be omitted from the coverage report. See examples/coffee folder.

See example examples/browser

The MIT License, see MIT-License.txt

Gleb Bahmutov