Skip to content

Commit

Permalink
build: use nyc for test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 19, 2020
1 parent 30c0871 commit f023828
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.nyc_output
coverage
node_modules
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.nyc_output/
coverage/
node_modules/
npm-debug.log
Expand Down
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,20 @@ before_install:
# Configure eslint for linting
if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)'
fi
- |
# Configure istanbul for coverage
if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$'
fi
- |
# Configure mocha for testing
if node_version_lt '0.10'; then npm_use_module 'mocha' '2.5.3'
elif node_version_lt '4.0' ; then npm_use_module 'mocha' '3.5.3'
elif node_version_lt '6.0' ; then npm_use_module 'mocha' '5.2.0'
elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2'
fi
- |
# Configure nyc for coverage
if node_version_lt '0.10'; then npm_remove_module_re '^nyc$'
elif node_version_lt '4.0' ; then npm_use_module 'nyc' '10.3.2'
elif node_version_lt '6.0' ; then npm_use_module 'nyc' '11.9.0'
elif node_version_lt '8.0' ; then npm_use_module 'nyc' '14.1.1'
fi
- |
# Configure supertest for http calls
if node_version_lt '0.10'; then npm_use_module 'supertest' '1.1.0'
Expand All @@ -88,8 +91,8 @@ before_install:
fi
script:
- |
# Run test script, depending on istanbul install
if npm_module_installed 'istanbul'; then npm run-script test-travis
# Run test script, depending on nyc install
if npm_module_installed 'nyc'; then npm run-script test-ci
else npm test
fi
- |
Expand All @@ -99,7 +102,7 @@ script:
after_script:
- |
# Upload coverage to coveralls
if [[ -f ./coverage/lcov.info ]]; then
if [[ -d .nyc_output ]]; then
npm install --save-dev coveralls@2
coveralls < ./coverage/lcov.info
nyc report --reporter=text-lcov | coveralls
fi
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"eslint-plugin-node": "9.2.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"istanbul": "0.4.5",
"mocha": "7.1.1",
"nyc": "15.0.0",
"split": "1.0.1",
"supertest": "4.0.2"
},
Expand All @@ -46,7 +46,7 @@
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --check-leaks --reporter spec --bail",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec"
"test-ci": "nyc --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}

0 comments on commit f023828

Please sign in to comment.