我的React Javascript的代码覆盖Sonar Qube



以下是我为React JavaScript应用程序提供的覆盖范围。我通过运行npm test在本地获得了报道,但在SonarQube中没有报道。有人能帮我弥补我所缺的吗?

渐变

// gradle sonar plugin configuration
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.projectName", "${project_name}-${version}"
property "sonar.projectKey", "${project_name}-$version}"
property "sonar.sources", "src/main/java/com/company/app,src/main/webapapp/appName/src"
property "sonar.exclusions", "src/main/webapp/appName/src/assests/**"
// Where to find tests file, also src
property "sonar.tests", "src/main/java/com/company/app,src/main/webapp/appName/src"
// But we get specific here
// We do not need to exclude it in sonar.sources because it is automatically taken care of
property "sonar.test.inclusions", "src/**/*.spec.js,src/**/*.spec.jsx,src/**/*.test.js,src**/*.test.jsx"
// Now specify path of lcov and test log
property "sonar.javascript.lcov.reportPaths", "src/main/webapp/appName/coverage/lcov.info"
//property "sonar.testExecutionReportPaths", "src/main/webapp/appName/coverage-final.json // does not work        

声纳项目。属性

# Source
sonar.sources=src
# Where to find tests file, also src
sonar.tests=src
# But we get specific here
# We do not need to exclude it in sonar.sources because it is automatically taken care of  
sonar.test.inclusions=src/**/*.spec.js,src/**/*.spec.jsx,src/**/*.test.js
,src/**/*.test.jsx
#sonar.testExecutionReportPaths=coverage/jest/testlog.xml

package.json

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest --coverage",
"eject": "react-scripts eject"
},
"jest": {
"transform":{
"^.+\.[t|j]sx?$": "babel-jest"
},
"collectCoverage": true,
"testResultsProcessor":"jest-sonar-reporter"
},
"homepage": "./",
"devDependencies": {
"jest": "^24.9.0",
"jest-junit-reporter: "^1.1.0"
},
...... removed for brevity

jest-sonar-reporter软件包很旧,已经4年没有更新了。它存在路径未按预期工作和未报告的问题。

我已经更新了插件,并在@casualbot/jest-sonar-reporter下重新发布,以修复此功能,并为社区添加其他功能。

例如:

package.json
{
...,
"jest": {
"rootDir": ".",
"testResultsProcessor": "@casualbot/jest-sonar-reporter"
},
"@casualbot/jest-sonar-reporter": {
"suiteName": "jest tests",
"outputDirectory": "coverage",
"outputName": "jest-report.xml",
"uniqueOutputName": "false",
"classNameTemplate": "{classname}-{title}",
"titleTemplate": "{classname}-{title}",
"ancestorSeparator": " › ",
"usePathForSuiteName": "true",
"relativePaths": "true"
}
}

披露:我是插件的开发者。

最新更新