1

Sonarqube 目前正在报告项目的百分比覆盖率,而不是单元测试的数量。我正在使用 jest-sonar-reporter,因此在测试运行后会生成一个 test-report.xml 文件。查看 Sonarqube 日志,它说为 0 个文件导入了测试执行数据。

INFO: Parsing /builds/REPONAME/coverage/test-report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 153 unknown files, including:
*file names*

我的 test-report.xml 文件中的文件路径是:

<file path="/builds/REPONAME/src/accounts/.../utils.test.ts">
<file path="/builds/REPONAME/src/shared/.../utils.test.js">
etc.

package.json 文件:

  "devDependencies": {
    ...
    "jest-sonar-reporter": "2.0.0",
    ...
  },
  "jestSonar": {
    "reportPath": "coverage",
    "reportFile": "test-report.xml",
    "indent": 4
  },

声纳项目.properties 文件:

sonar.projectName=REPONAME
sonar.projectVersion=3.46.1
sonar.language=js
sonar.sources=src
sonar.tests=src
sonar.exclusions=node_modules/**,tests/**,.idea/**,.storybook/**,stories/**
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.test.inclusions=**/*.test.*
sonar.coverage.exclusions=node_modules/**,test/**,src/**/*.test.js,src/**/*.test.jsx,server/**/*.test.js,*.config.js,.idea/**,.storybook/**,stories/**,**/__snapshots__/**/*
sonar.eslint.reportPaths=eslint.json
sonar.testExecutionReportPaths=coverage/test-report.xml
4

0 回答 0