Open subashiniunny opened 4 years ago
I had the same issue and was able to work around the issue by using the filenameFormatter
config option to define a custom formatter for the path (overrideTestDescription must be false).
It looks like that overrideTestDescription
was a better path for us (unfortunately, it seems that filenameFormatter
as previously suggested doesn't provide current file path) :
sonarQubeUnitReporter: {
sonarQubeVersion: "LATEST",
outputDir: "coverage/",
outputFile: "test-report.xml",
useBrowserName: false,
overrideTestDescription: true,
testPaths: ['./test'],
testFilePattern: /\.test\.[jt]sx?$/,
prependTestFileName: "apps/portal"
}
Thanks @gfortaine ,
You make my day.
Thanks a lot @gfortaine That works for me and I fix it with adding prefix of absolute path
sonarQubeUnitReporter: {
sonarQubeVersion: "9.x",
outputFile: "./coverage/unit-test-result.xml",
overrideTestDescription: true,
testFilePattern: ".spec.ts",
useBrowserName: false,
prependTestFileName: __dirname
}
As a part of the drop of modules on the SonarQube side (https://jira.sonarsource.com/browse/MMF-365) in SonarQube v7.6, the generic coverage/test reports sensors were changed to be global sensors (https://jira.sonarsource.com/browse/SONAR-11530), meaning they only run once for the project (and not for each module). To address this, we need to provide the paths to all generic execution reports to sonar.testExecutionReportPaths at the root level of the project. In the case of a multi-module project, we have the generic test report using this karma-sonarqube-unit-reporter being generated inside a javascript module and the file path of the test files inside the results xml file is all relative to that module. This does not work. These test file paths need to be relative to the root folder or absolute file paths, otherwise the generic test execution sensor running at the root level is unable to recognize these files.