-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from piuccio/coverage
Documentation on code coverage
- Loading branch information
Showing
7 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ node_modules | |
.DS_Store | ||
.gitignore | ||
npm-debug.log | ||
examples/coverage/tmp | ||
examples/coverage/instrumented |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module.exports = function(grunt) { | ||
"use strict"; | ||
|
||
grunt.initConfig({ | ||
testem: { | ||
options : { | ||
launch_in_ci : ['Chrome'], | ||
output: { | ||
coverage: 'tmp/coverage/from_browsers/' | ||
}, | ||
routes: { | ||
"/lib": "../lib", | ||
"/src": "instrumented" | ||
} | ||
}, | ||
all : { | ||
files : { | ||
'tmp/result.tap': ['test/index.html'] | ||
} | ||
} | ||
}, | ||
|
||
clean: { | ||
tests: ['tmp'] | ||
}, | ||
|
||
// This section is to instrument files from grunt | ||
shell: { | ||
instrument: { | ||
command: "istanbul instrument --output instrumented src" | ||
}, | ||
report: { | ||
command: "istanbul report --root tmp/coverage/from_browsers --dir tmp/coverage lcov" | ||
}, | ||
options: { | ||
stdout: true, | ||
failOnError: true | ||
} | ||
} | ||
}); | ||
|
||
// In real life replace this line: | ||
grunt.loadTasks('../../tasks'); | ||
// with | ||
// grunt.loadNpmTasks('grunt-testem'); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-shell'); | ||
|
||
|
||
grunt.registerTask('test', ['clean', 'shell:instrument', 'testem', 'shell:report']); | ||
grunt.registerTask('default', ['test']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "grunt-testem-coverage-example", | ||
"description": "A grunt plugin for testem using code coverage.", | ||
"version": "0.0.0-whatever", | ||
"homepage": "https://github.com/sideroad/grunt-testem", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/sideroad/grunt-testem.git" | ||
}, | ||
"dependencies": { | ||
"async": "~0.1.22", | ||
"underscore": "~1.4.2", | ||
"testem-multi": "~0.3.1", | ||
"grunt-contrib-clean": "~0.4.0", | ||
"grunt": "~0.4.2", | ||
"grunt-shell": "~0.6.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function sayHello (name, capital) { | ||
return "Hello " + (!!capital ? name.toUpperCase() : name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>QUnit Example</title> | ||
<link rel="stylesheet" href="../../lib/qunit.css"> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<script src="../../lib/qunit.js"></script> | ||
<script src="/testem.js"></script> | ||
|
||
<script src="../src/hello.js"></script> | ||
<script> | ||
test("say hello", function () { | ||
equal(sayHello("testem-multi", true), "Hello TESTEM-MULTI"); | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters