Skip to content

Commit

Permalink
Adding code coverage for both specs and tests, in Node.
Browse files Browse the repository at this point in the history
Uses itay/node-cover. Run with:

    npm run-script test-cover
    npm run-script spec-cover

Both will generate cover_html folders with an index.html containing the coverage report. There unfortunately doesn't seem to be a cross-platform way of automatically launching that index.html in your default browser [1].

This reveals a few missing spots, in addition to large swathes of untested-but-that's-OK code (like shims and long stack trace code).

Ideally we would be able to run this in different browser environments (e.g. to make sure the shims are covered), but that would require a decent bit more work, I believe.

NB some small additions were necessary to make the Jasmine specs run in Node.

[1]: http://superuser.com/questions/38984/linux-equivalent-command-for-open-command-on-mac-windows
  • Loading branch information
domenic committed May 18, 2012
1 parent aa6c0de commit 520f016
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .coverignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/
spec/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
node_modules
CHANGES.html
README.html

.coverage_data/
.coverage_debug/
cover_html/
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@
"dependencies": {},
"devDependencies": {
"test": ">=0.3.0",
"jshint": "*"
"jshint": "*",
"cover": "*",
"jasmine-node": "*"
},
"scripts": {
"test": "node test/all.js"
"test": "node test/all.js",
"test-cover": "cover run test/all.js && cover report html",
"spec-cover": "cover run node_modules/jasmine-node/bin/jasmine-node spec && cover report html"
},
"overlay": {
"teleport": {
Expand Down
4 changes: 4 additions & 0 deletions spec/q-spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if (typeof Q === "undefined" && typeof require !== "undefined") {
// For Node compatability.
this.Q = require("../q");
}

describe("defer and when", function () {

Expand Down

0 comments on commit 520f016

Please sign in to comment.