0

In my Angular project hosted on GitHub, I'm running the tests in TravisCI using:

package.json scripts

 "test-ci": "ng test --watch=false"

.travis.yml script

script:
  - ng lint
  - npm run test-ci
  - npm run e2e
  - npm run build

I would like to set up coveralls, however from the official documentation and articles on the web it is not super clear what I have to do.

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252

2 Answers2

1

I solved by simply using node-coveralls.

What I had to do was just installing it:

npm install coveralls --save-dev

And then in my package.json scripts change:

 "test-ci": "ng test --watch=false"

to:

 "test-ci": "ng test --watch=false --code-coverage && cat ./coverage/lcov.info | coveralls"
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
0

While I do like what @Francesco Borzi mentioned but keeping ci in mind I think we need to do it in two steps, you don't have to publish this for a pull request unless its a success. You could fail the build

  1. run the test as part of the initial step
  2. publish the output from the above step to coveralls

script: - ng test --watch=false after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

paul58914080
  • 282
  • 3
  • 8