view raw
Colin Weber Colin Weber - 11 months ago 86
Node.js Question

how to prevent mocha from exiting process with status 1

I have written a simple node.js application and now I want to add some tests. For now I have only some example Tests to test my Gitlab-CI, SonarQube and Mocha, which i am using for testing.

Now my problem is, that I want to parse the results from mocha (reporter is the sonar-mocha-reporter). My problem is that mocha exits the process with status 1 if a test is failing. That means gitlab-ci is breaking the build and will not run to the end. So i can not parse the results like it should.

Is there a way to configure mocha to not break my build so that it only saves the results in this xml file?

I am starting mocha with:

./node_modules/.bin/mocha -R mocha-sonar-reporter --recursive --no-exit

and in my package.json i have the configuration:

"config": {
"mocha-sonar-reporter": {
"outputfile": "build/reports/tests/TEST-mocha.xml"


Perhaps can you just do:

./node_modules/.bin/mocha || true

If it fails, it will then return true, and be successful.