Skip to content

Commit 4b5db12

Browse files
committed
build: use nyc for test coverage
1 parent 7be0e04 commit 4b5db12

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ before_install:
6464
# Configure eslint for linting
6565
if node_version_lt '10.0'; then npm_remove_module_re '^eslint(-|$)'
6666
fi
67-
- |
68-
# Configure istanbul for coverage
69-
if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$'
70-
fi
7167
- |
7268
# Configure mocha for testing
7369
if node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3'
@@ -76,6 +72,13 @@ before_install:
7672
elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2'
7773
elif node_version_lt '10.0'; then npm_use_module 'mocha' '7.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'
@@ -90,9 +93,9 @@ before_install:
9093
npm rebuild
9194
fi
9295
script:
93-
# Run test script, depending on istanbul install
96+
# Run test script, depending on nyc install
9497
- |
95-
if npm_module_installed 'istanbul'; then npm run-script test-travis
98+
if npm_module_installed 'nyc'; then npm run-script test-ci
9699
else npm test
97100
fi
98101
# Run linting, depending on eslint install
@@ -102,7 +105,7 @@ script:
102105
after_script:
103106
# Upload coverage to coveralls if exists
104107
- |
105-
if [[ -f ./coverage/lcov.info ]]; then
108+
if [[ -d .nyc_output ]]; then
106109
npm install --save-dev coveralls@2
107-
coveralls < ./coverage/lcov.info
110+
nyc report --reporter=text-lcov | coveralls
108111
fi

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"eslint": "7.26.0",
2323
"eslint-plugin-markdown": "2.1.0",
2424
"finalhandler": "1.1.2",
25-
"istanbul": "0.4.5",
2625
"mocha": "8.4.0",
26+
"nyc": "15.1.0",
2727
"safe-buffer": "5.2.1",
2828
"supertest": "6.1.3"
2929
},
@@ -40,8 +40,8 @@
4040
"scripts": {
4141
"lint": "eslint .",
4242
"test": "mocha --reporter spec --bail --check-leaks test/",
43-
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
44-
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
43+
"test-ci": "nyc --reporter=html --reporter=text npm test",
44+
"test-cov": "nyc --reporter=text npm test",
4545
"version": "node scripts/version-history.js && git add HISTORY.md"
4646
}
4747
}

0 commit comments

Comments
 (0)