如何使用is-sonar-reporter?
How to use jest-sonar-reporter?
如何使用jest-sonar-reporter?在 config.json
中我们使用 "testResultsProcessor": "/config/jest/resultsProcessor"
:
resultsProcessor.js
module.exports = (results) => {
process.env.TEST_REPORT_PATH = root('reports/unit')
process.env.JEST_SUITE_NAME = 'React Unit Tests'
process.env.JEST_JUNIT_OUTPUT = root('reports/unit/junit.xml')
require(root('node_modules/jest-sonar-reporter/index')).apply(this, [results])
require(root('node_modules/jest-junit/index')).apply(this, [results])
// add any other processor you need
return results
}
这在我们使用 "jest": "^21.2.1"
时工作正常,
但在将 Jest 更新为 "jest": "^26.1.0"
、
之后
根据文档...
"reporters": [ "default",[
"jest-junit", {
"outputDirectory":"reports/unit",
"suiteName": "ANZ-React-BoilerPlate Unit Tests",
"outputName": "junit.xml"
}]],
jest-junit
工作正常,但如何支持 jest-sonar-reporter
?
我使用 jest-sonar npm 包解决了这个问题。
如何使用jest-sonar-reporter?在 config.json
中我们使用 "testResultsProcessor": "/config/jest/resultsProcessor"
:
resultsProcessor.js
module.exports = (results) => {
process.env.TEST_REPORT_PATH = root('reports/unit')
process.env.JEST_SUITE_NAME = 'React Unit Tests'
process.env.JEST_JUNIT_OUTPUT = root('reports/unit/junit.xml')
require(root('node_modules/jest-sonar-reporter/index')).apply(this, [results])
require(root('node_modules/jest-junit/index')).apply(this, [results])
// add any other processor you need
return results
}
这在我们使用 "jest": "^21.2.1"
时工作正常,
但在将 Jest 更新为 "jest": "^26.1.0"
、
根据文档...
"reporters": [ "default",[
"jest-junit", {
"outputDirectory":"reports/unit",
"suiteName": "ANZ-React-BoilerPlate Unit Tests",
"outputName": "junit.xml"
}]],
jest-junit
工作正常,但如何支持 jest-sonar-reporter
?
我使用 jest-sonar npm 包解决了这个问题。