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 May 17, 2021
1 parent 7be0e04 commit 4b5db12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
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 @@ -64,10 +64,6 @@ before_install:
# Configure eslint for linting
if node_version_lt '10.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'
Expand All @@ -76,6 +72,13 @@ before_install:
elif node_version_lt '8.0' ; then npm_use_module 'mocha' '6.2.2'
elif node_version_lt '10.0'; then npm_use_module 'mocha' '7.2.0'
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 @@ -90,9 +93,9 @@ before_install:
npm rebuild
fi
script:
# Run test script, depending on istanbul install
# Run test script, depending on nyc install
- |
if npm_module_installed 'istanbul'; then npm run-script test-travis
if npm_module_installed 'nyc'; then npm run-script test-ci
else npm test
fi
# Run linting, depending on eslint install
Expand All @@ -102,7 +105,7 @@ script:
after_script:
# Upload coverage to coveralls if exists
- |
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 @@ -22,8 +22,8 @@
"eslint": "7.26.0",
"eslint-plugin-markdown": "2.1.0",
"finalhandler": "1.1.2",
"istanbul": "0.4.5",
"mocha": "8.4.0",
"nyc": "15.1.0",
"safe-buffer": "5.2.1",
"supertest": "6.1.3"
},
Expand All @@ -40,8 +40,8 @@
"scripts": {
"lint": "eslint .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-ci": "nyc --reporter=html --reporter=text npm test",
"test-cov": "nyc --reporter=text npm test",
"version": "node scripts/version-history.js && git add HISTORY.md"
}
}

0 comments on commit 4b5db12

Please sign in to comment.