B.O*_*ara 9 reactjs sonarqube jestjs sonarjs
我在配置 sonarqube 时遇到问题,无法与 React + Jest 一起正常工作。
我的配置:
my_moudle.sonar.projectBaseDir=front_app
my_module.sonar.javascript.file.suffixes=.js,.jsx
my_module.sonar.tests=src
my_module.sonar.test.inclusions=**/__tests__/** my_module.sonar.javascript.lcov.reportPaths=coverage/lcov.info
目前我将 src 文件夹指向为测试文件夹,因为我在同一项目文件夹中的测试文件夹中为每个组件设置了一组测试。感谢 SonarJS,我对我的项目有适当的覆盖,但我不知道为什么我看不到覆盖度量指标中的单元测试数量。任何检查的配置将不胜感激。
谢谢,巴布
dub*_*bes 15
SonarJS 不负责单元测试报告,(相关FAQ 条目)导入单元测试报告是SonarQube 的责任。
我已经通过以下设置设法做到了。
首先,我们需要将笑话结果转换为声纳耗材格式。为此,我使用了以下 npm 模块:jest-sonar-reporter。
我的片段package.json:
"devDependencies": {
...
"jest": "^21.1.0",
"jest-sonar-reporter": "^1.3.0",
...
},
"jestSonar": {
"sonar56x": true,
"reportPath": "testResults",
"reportFile": "sonar-report.xml",
"indent": 4
}
Run Code Online (Sandbox Code Playgroud)
您现在需要告诉 jest 将此模块用作处理器,并告诉声纳扫描仪使用此模块生成的文件。说明在官方文档中。
如果您使用 create-react-app/react-scripts,您可能需要一些额外的步骤,因为它们不会公开所有配置。
您需要将scriptspackage.json 中的test in block条目修改为:
"test": "react-scripts test --env=jsdom --testResultsProcessor <pathToNodeModules/jestSonarReporter/index.js>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15213 次 |
| 最近记录: |