如何防止摩卡离开状态为1的过程

我写了一个简单的node.js应用程序,现在我想添加一些testing。 现在我只有一些示例testing来testing我用于testing的Gitlab-CI,SonarQube和Mocha。

现在我的问题是,我想parsing摩卡的结果(记者是声纳 – 摩卡记者)。 我的问题是,如果testing失败,mocha退出状态为1的进程。 这意味着gitlab-ci打破了构build,不会跑到最后。 所以我不能像解释结果一样。

有没有办法configuration摩卡不破坏我的构build,以便它只保存在这个XML文件中的结果?

我开始摩卡:

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

并在我的package.json我有configuration:

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

也许你可以做:

 ./node_modules/.bin/mocha || true 

如果失败了,那么它将会返回true ,并成功。

将参数silent添加到命令行。 例如:

npm run test --silent