Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
- what are you trying to achieve
- what have you tried so far to achieve this
Sonarqube(v 8.9.4) is set up in the gitlab pipeline to analyze the test coverage. In the Sonarqube dashboard, the coverage percent is displayed, but not the number of unit tests.
jest-sonar-reporter(v 2.0.0) is being used in the test stage to generate a test-reporter.xml file and then when Sonarqube runs, it grabs that artifact from the test stage.
In the Sonarqube log, it is showing:
INFO: Parsing /builds/TkDiTxQV/0/REPONAME/coverage/test-reporter.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 153 unknown files, including:
/builds/REPONAME/src/accounts/asset_allocations_summary_card/components/current_path/target_allocation/utils.test.ts
/builds/REPONAME/src/shared/components/sale_strategies/utils.test.js
/builds/REPONAME/src/accounts/distributions/utils/distribution_primary.utils.test.js
/builds/REPONAME/src/accounts/distributions/utils/distribution_ui.utils.test.js
/builds/REPONAME/src/accounts/distributions/utils/distribution_events.utils.test.js
This is the sonar-project.properties file:
sonar.projectName=REPONAME
sonar.projectVersion=3.46.1
sonar.language=js
sonar.tests=src
sonar.sources=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-reporter.xml
sonar.gitlab.only_issue_from_commit_line=true
sonar.gitlab.failure_notification_mode=exit-code
sonar.gitlab.comment_no_issue=true
sonar.qualitygate.wait=true
These are the file paths in the test-reporter.xml file:
<file path="/builds/REPONAME/src/accounts/asset_allocations_summary_card/components/current_path/target_allocation/utils.test.ts">
<file path="/builds/REPONAME/src/shared/components/sale_strategies/utils.test.js">
<file path="/builds/REPONAME/src/accounts/distributions/utils/distribution_primary.utils.test.js">
etc..
I first tried messing around with the inclusions/exclusions, but that did not work.
Then, I look at similar questions asked on this site and tried adding the sonar.projectBaseDir
property, but that did not work either.
It seems the issue is the filepaths in the test-reporter.xml file but I cannot find a solution that works for me. The weird part is I’ve been able to get the number of unit tests to show in other projects with no issues at all, but for some reason I cannot get it to work for this project.