首页 > 解决方案 > SonarQube unit test report doesnt show Javascript files

问题描述

I have a maven project with modules in both Java and Javascript. I am not seeing the Javascript unit test files in test report in SonarQube but only Java unit test files. coverage_reports

In coverage_reports folder I have cobertura-coverage.xml created by Jest. Is this sonar.javascript.jstest.reportPaths still used or has it been replaced by some other configuration. We are using Sonarqube 6.7 at our server.

Edit: For others to know, I used jest-sonar-reporter and test script as

"test": "cross-env CI=true NODE_PATH=./src react-scripts test --env=jsdom --coverage --no-cache -u --testResultsProcessor jest-sonar-reporter"

This created a test report xml file that I used like this

<sonar.tests>src/test</sonar.tests>
<sonar.testExecutionReportPaths>path/to/test-report.xml</sonar.testExecutionReportPaths>
<sonar.javascript.lcov.reportPaths>path/to/lcov.info</sonar.javascript.lcov.reportPaths>

标签: javascriptsonarqubesonarqube-scan

解决方案


As far as I can say sonar.javascript.jstest.reportPaths doesn't exist (and never did).

There are 2 things (from question I'm not sure which one you need):

  1. Unit test report import (how many unit tests, which failed, which skipped etc). For that, see doc here (you will need to use sonar.testExecutionReportPaths property eventually).
  2. Coverage report import. If you are able to produce LCOV see doc here. If not, you will need to convert your report in generic SonarQube format (see here).

Finally, to see unit test files for JS, set correctly sonar.tests property (Java test files are displayed due to smart enough maven scanner)


推荐阅读