JavaScript Unit Testing: QUnit, Jasmine, Coverage, and Automation
Table of Contents
1. Unit Tests
1.1. QUnit
Why not Jasmine, YUITest, etc.
1.2. Application setup
- Stand-alone
- YUITest
- PhantomJS is universally required
2. Coverage
2.1. AST: Esprima
corrected
the quoted header is UglifyJS's bundled parser (by Mihai Bazon, porting Marijn Haverbeke's Common Lisp parse-js), not Esprima's — Esprima was written independently by Ariya Hidayat.
A JavaScript tokenizer / parser / beautifier / compressor. This version is suitable for Node.js. With minimal changes (the exports stuff) it should work on any JS platform. This file contains the tokenizer/parser. It is a port to JavaScript of parse-js [1], a JavaScript parser library written in Common Lisp by Marijn Haverbeke. Thank you Marijn! [1] http://marijn.haverbeke.nl/parse-js/
Note: the quote above is UglifyJS's parser header.
2.2. Static: node-cover
correct
See Itay's talk on this from http://www.meetup.com/Seattle-Node-js/events/59999252/
https://github.com/itay/node-cover
See also
2.3. Build: grunt-coverjs
corrected
the registered grunt task is `cover` (grunt.registerMultiTask('cover', ...) in tasks/cover.js); `instrumented` names the output directory in the README's sample config, not a runnable task — `grunt instrumented` does not invoke this plugin.
https://github.com/jgrund/grunt-coverjs
$ grunt cover
if (typeof __$coverObject === "undefined"){
if (typeof window !== "undefined") window.__$coverObject = {};
else if (typeof global !== "undefined") global.__$coverObject = {};
else throw new Error("cannot find the global scope");
}