Skip to content

Commit c6856db

Browse files
committed
build: use nyc for test coverage
1 parent a13c073 commit c6856db

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.nyc_output/
12
coverage/
23
node_modules/
34
npm-debug.log

.travis.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,19 @@ before_install:
6666
# Configure eslint for linting
6767
if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)'
6868
fi
69-
- |
70-
# Configure istanbul for coverage
71-
if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$'
72-
fi
7369
- |
7470
# Configure mocha for testing
7571
if node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3'
7672
elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3'
7773
elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0'
7874
fi
75+
- |
76+
# Configure nyc for coverage
77+
if node_version_lt '0.10'; then npm_remove_module_re '^nyc$'
78+
elif node_version_lt '4.0' ; then npm_use_module 'nyc' '10.3.2'
79+
elif node_version_lt '6.0' ; then npm_use_module 'nyc' '11.9.0'
80+
elif node_version_lt '8.0' ; then npm_use_module 'nyc' '14.1.1'
81+
fi
7982
- |
8083
# Configure supertest for http calls
8184
if node_version_lt '0.10'; then npm_use_module 'supertest' '1.1.0'
@@ -95,8 +98,8 @@ before_scrpt:
9598
npm -s ls ||:
9699
script:
97100
- |
98-
# Run test script, depending on istanbul install
99-
if npm_module_installed 'istanbul'; then npm run-script test-travis
101+
# Run test script, depending on nyc install
102+
if npm_module_installed 'nyc'; then npm run-script test-travis
100103
else npm test
101104
fi
102105
- |
@@ -105,8 +108,8 @@ script:
105108
fi
106109
after_script:
107110
- |
108-
# Upload coverage to coveralls if exists
109-
if [[ -e ./coverage/lcov.info ]]; then
111+
# Upload coverage to coveralls
112+
if [[ -d .nyc_output ]]; then
110113
npm install --save-dev coveralls@2
111-
coveralls < ./coverage/lcov.info
114+
nyc report --reporter=text-lcov | coveralls
112115
fi

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
"eslint-plugin-node": "9.2.0",
2929
"eslint-plugin-promise": "4.2.1",
3030
"eslint-plugin-standard": "4.0.1",
31-
"istanbul": "0.4.5",
3231
"methods": "1.1.2",
3332
"mocha": "6.2.2",
33+
"nyc": "15.0.0",
3434
"safe-buffer": "5.2.0",
3535
"supertest": "4.0.2"
3636
},
@@ -46,7 +46,7 @@
4646
"scripts": {
4747
"lint": "eslint --plugin markdown --ext js,md .",
4848
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
49-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/",
50-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/"
49+
"test-cov": "nyc --reporter=html --reporter=text npm test",
50+
"test-travis": "nyc --reporter=text npm test"
5151
}
5252
}

0 commit comments

Comments
 (0)