From f023828af48704571eea479ce51c044017098f65 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 19 Mar 2020 14:09:19 -0400 Subject: [PATCH] build: use nyc for test coverage --- .eslintignore | 1 + .gitignore | 1 + .travis.yml | 19 +++++++++++-------- package.json | 6 +++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.eslintignore b/.eslintignore index 62562b7..76b1021 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ +.nyc_output coverage node_modules diff --git a/.gitignore b/.gitignore index 0fa6951..f15b98e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.nyc_output/ coverage/ node_modules/ npm-debug.log diff --git a/.travis.yml b/.travis.yml index b930810..be27b3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,10 +62,6 @@ 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' @@ -73,6 +69,13 @@ before_install: 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' @@ -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 - | @@ -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 diff --git a/package.json b/package.json index fe87e51..b626d85 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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" } }