Here is my .travis.yml
:
language: node_js
notifications:
email:
on_success: never
on_failure: change
node_js:
- "stable"
before_install:
- npm install -g npm
script:
- npm run verify
after_script:
- npm install coveralls && npm run coveralls
And here is my package.json
:
{
...
"scripts": {
"coverage": "npm test && nyc check-coverage --branches 85 --functions 85 --lines 85",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"test": "npm run clean && tsc && nyc ava"
...
},
"nyc": {
"exclude": [
"scripts",
"**/*.spec.*",
"**/fixtures/**/*"
]
},
...
}
Hey @Spineswitch,
When it comes to nyc
, your package.json
looks just fine, it’s more to do with your .travis.yml
config when I look at it all in aggregate.
I just made this repository today, you’d find it of great use probably: GitHub - Montana/travis-nyc: Travis w/ nyc by Montana Mendy.
The .travis.yml
I coded out is more instructional and declarative based, for example:
services:
- docker
language: node_js
node_js:
- 17
script:
- npm init --yes
- npm i express mocha chai supertest nyc mongoose
- sudo apt-get install gnupg
- wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
- sudo apt-get install -y mongodb-org
- sudo systemctl start mongod
- node bin/www &
- npm install -g nyc
- nyc --version
- nyc npm run test
It’s very straight forward, in this scenario - I made a quick app in JavaScript, gave it mock MongoDB credentials, had it connect to Mongo with node bin/www &
, and you can see where I fetched nyc
, etc. This worked out perfectly for me. This doesn’t cover coveralls
I understand, but same implementation of coveralls
would apply. Get the environment variables from coveralls
add them in Travis, and you’d have more code coverage.
For one of my projects using nyc
and coveralls
this is a snippet of my travis.yml
that maybe can help you:
jobs:
include:
- script: COVERALLS_FLAG_NAME=test-1 make test-coveralls-1
- script: COVERALLS_FLAG_NAME=test-2 make test-coveralls-2
- script: npm install coveralls nyc --save-dev
notifications:
webhooks: https://coveralls.io/webhook
after_success: npm run coverage
This is a private repo so I can only give you this snippet but should point you in the right direction.
1 Like
thank you so much @montana! this worked perfectly