Skip to content

Commit c2f082b

Browse files
committed
Set the project up for code coverage.
To run locally: $ npm run test:cover && open .coverage/index.html Should also start sending to codeclimate if I configured it right. (At this time, our only uncovered code is due to Proxy not being supported in Node.js; there's a test if we run against FF)
1 parent 5101e03 commit c2f082b

7 files changed

+37
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ npm-debug.log*
88

99
/generated
1010
/lib
11+
/.coverage

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ node_js:
33
- "4.1"
44
- "0.12"
55
script: npm run test:ci
6+
after_script:
7+
- npm run test:cover
8+
- npm run test:cover:report
9+
addons:
10+
code_climate:
11+
repo_token: c92188dcdeaca7d9732f8ea38fdd41d6bff18dc27a8d6f8b64a5b1311b7b6c21

package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
"mocha_reporter": "dot"
1515
},
1616
"scripts": {
17-
"clean": "rm -rf generated dist lib && git checkout -- dist",
17+
"clean": "rm -rf generated dist lib .coverage && git checkout -- dist",
1818
"compile:node": "coffee --output lib --compile src",
1919
"compile:test": "coffee --output generated/test --compile test",
2020
"compile:browser": "browserify . --standalone td --outfile $npm_package_config_build_file --ignore 'quibble' -p headerify",
2121
"compile": "npm run compile:node && npm run compile:test && npm run compile:browser",
22-
"test": "mocha --ui mocha-given --reporter $npm_package_config_mocha_reporter --compilers coffee:coffee-script --recursive test/node-helper.coffee test/src",
22+
"test": "mocha --ui mocha-given --reporter $npm_package_config_mocha_reporter --compilers coffee:coffee-script $EXTRA_MOCHA_ARGS --recursive test/node-helper.coffee test/src",
23+
"test:cover:instrument": "istanbul instrument lib -o .coverage/lib",
24+
"test:cover:run": "EXTRA_MOCHA_ARGS=\"--reporter mocha-istanbul\" COVER=.coverage/lib ISTANBUL_REPORT_DIR=.coverage ISTANBUL_REPORTERS=lcov,html npm run test",
25+
"test:cover:report": "codeclimate-test-reporter < .coverage/lcov.info",
26+
"test:cover": "npm run compile:node && npm run test:cover:instrument && npm run test:cover:run",
2327
"test:browser": "npm run compile && testem ci",
2428
"test:example:webpack": "cd examples/webpack && npm i && npm test & cd ../..",
2529
"test:example:node": "cd examples/node && npm i && npm test && cd ../..",
@@ -46,11 +50,14 @@
4650
"devDependencies": {
4751
"browserify": "^11.0.1",
4852
"chai": "^3.2.0",
53+
"codeclimate-test-reporter": "^0.3.1",
4954
"coffee-script": "^1.10.0",
5055
"disc": "^1.3.2",
5156
"headerify": "^1.0.1",
57+
"istanbul": "^0.4.2",
5258
"mocha": "^2.3.1",
5359
"mocha-given": "^0.1.3",
60+
"mocha-istanbul": "arikon/mocha-istanbul",
5461
"testem": "^0.9.4"
5562
},
5663
"keywords": [

test/node-helper.coffee

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
global.td = require('./../src/testdouble')
1+
sourceDir = if process.env.COVER?
2+
process.env.COVER
3+
else
4+
'src'
5+
6+
global.requireSource = (path) ->
7+
require("#{process.cwd()}/#{sourceDir}/#{path}")
8+
9+
global.td = requireSource('testdouble')
210
global.chai = require('chai')
311
global.NODE_JS = true
412

13+
514
require('./general-helper')

test/src/matchers-test.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
matches = (expected, actual) ->
22
if NODE_JS
3-
require('../../src/args-match')([expected], [actual], {})
3+
requireSource('args-match')([expected], [actual], {})
44
else
55
expected.__matches(actual)
66

test/src/stringify/anything-test.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ return unless NODE_JS
22

33

44
describe 'stringify/anything', ->
5-
Given -> @subject = require('../../../src/stringify/anything')
5+
Given -> @subject = requireSource('stringify/anything')
66
Then -> @subject(undefined) == "undefined"
77
And -> @subject(null) == "null"
88
And -> @subject(0) == "0"

test/src/testdouble-test.coffee

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ return unless NODE_JS
22

33
describe "td.*", ->
44
describe "where all the functions are", ->
5-
Then -> td.when == require('../../src/when')
6-
Then -> td.verify == require('../../src/verify')
7-
Then -> td.function == require('../../src/function')
8-
Then -> td.object == require('../../src/object')
9-
Then -> td.matchers == require('../../src/matchers')
10-
Then -> td.callback == require('../../src/matchers/callback')
11-
Then -> td.explain == require('../../src/explain')
12-
Then -> td.reset == require('../../src/reset')
13-
Then -> td.replace == require('../../src/replace/index')
5+
Then -> td.when == requireSource('when')
6+
Then -> td.verify == requireSource('verify')
7+
Then -> td.function == requireSource('function')
8+
Then -> td.object == requireSource('object')
9+
Then -> td.matchers == requireSource('matchers')
10+
Then -> td.callback == requireSource('matchers/callback')
11+
Then -> td.explain == requireSource('explain')
12+
Then -> td.reset == requireSource('reset')
13+
Then -> td.replace == requireSource('replace/index')
1414
Then -> td.version == require('../../package').version

0 commit comments

Comments
 (0)