Install and run
gt requires nodejs and a few modules to run. Assuming you wrote a few qunit tests in tests.js:
sudo npm install -g gtgt tests.jssome of the options
- Make sure QUnit tests work with istanbul JS coverage tool
- Experiment with JS unit testing by writing a framework from scratch.
A simple example is in examples subfolder
Unit tests follow QUnit approach:
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.
Running in browser
See example examples/browser
gt provides minimal BDD support and can run Mocha/Jasmine specs that have
See spec example. You can run it using
gt --bdd spec.js command.
Creates new suite of tests with given name
You can specify additional functions to run before / after each unit tests. You can also specify a function to run once before any tests, and after all tests.
See module tests for more information and examples.
A very convenient feature: each method can return a promise object to tell the test engine when it is done. See example
Spawns new proces, waits for it to finish, then checks the exit code. Automatically restarts the test queue
Checking just the exit code
Checking the exit code and the output
Full exec unit test
gt;// same asgt;gt;// same asgt;gt;// same asgt;
Performs deep equality comparison between two objects.
command line options
gt excludes certain common paths from coverage,
speeding up the test runs: node_modules, bower_components, etc.
You can add paths to this list, for example to exclude all files
gt --no-cover vendor src/*.js tests/*.js
The option is used as case insensitive regular expression.
Author: Gleb Bahmutov © 2014
License: MIT - do anything with the code, but don't blame me if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github.