admin管理员组

文章数量:1332383

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"
    }
  },

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"
    }
  },
Share Improve this question edited Apr 19, 2016 at 14:23 Jessica Weber asked Apr 19, 2016 at 14:07 Jessica WeberJessica Weber 1322 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

Perhaps can you just do:

./node_modules/.bin/mocha || true

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

Add parameter silent to mand line. For example:

npm run test --silent

本文标签: javascripthow to prevent mocha from exiting process with status 1Stack Overflow