Cristian Boariu Cristian Boariu - 1 year ago 89
Node.js Question

Why when test fails jenkins still says success?

I have a MEAN project. Using Jenkins on an EC2 machine I build this using the following shell script:

npm install && PORT=8888 npm test

mocha returns 2 (number of failing tests) but still jenkins says:

Finished: SUCCESS.

If tests are failing I expect to see

Finished: FAILURE

Do you know why its not working fine?

Answer Source

You can:

  1. Use a test runner like Karma, or
  2. Tell Mocha to report in, for example, XUnit format, by passing Mocha the --reporter xunit flag. XUnit closely aligns with JUnit which Jenkins understands, or
  3. Add in a custom reporter — mocha-jenkins-reporter is a decent option.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download