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 Jul 1, 2019
1 parent 4197b80 commit c3f140f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 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
22 changes: 21 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,25 @@ before_install:
# Setup npm
- "test $TRAVIS_NODE_VERSION != '0.8' || npm install -g npm@1.2.8000"
- "npm config set shrinkwrap false"
# Setup Node.js version-specific dependencies
- |
# nyc for coverage
# - remove for Node.js < 6
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
npm rm --silent --save-dev nyc
fi
script:
# Run test script
- |
if npm -ps ls nyc | grep -q nyc; then
npm run test-cov
else
npm test
fi
after_script:
- "test -e ./coverage/lcov.info && npm install coveralls@2 && coveralls < ./coverage/lcov.info"
- |
# Upload coverage to coveralls if exists
if [[ -d .nyc_output ]]; then
npm install --save-dev coveralls@2
nyc report --reporter=text-lcov | coveralls
fi
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ install:
- if "%nodejs_version%" equ "0.8" npm config set strict-ssl false
- if "%nodejs_version%" equ "0.8" npm install -g --prefix "%npm_prefix:~0,-1%" npm@1.2.8000
- npm config set shrinkwrap false
# Remove all non-test dependencies
- npm rm --silent --save-dev nyc
# Install Node.js modules
- npm install
build: off
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"walk": "2.3.14"
},
"devDependencies": {
"istanbul": "0.4.5",
"mocha": "2.5.3",
"nyc": "14.1.1",
"rimraf": "2.7.1",
"supertest": "1.1.0"
},
Expand All @@ -30,6 +30,7 @@
"npm": "1.2.8000 || >= 1.4.16"
},
"scripts": {
"test": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter spec test/*/index.js"
"test": "mocha --reporter spec test/*/index.js",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}

0 comments on commit c3f140f

Please sign in to comment.