I\'ve been trying to find out how to populate SonarQube with both my Jest Unit Tests and the .net Unit Tests.
I have a
Looks like I've figured out the way to make it work. The trick is to have both sonar.sources
and sonar.tests
point to same directory (because we have both tests and source in the same directory) then use sonar.tests.inclusions
to pattern match test files with .test.js
or .spec.js
extension.
Here's a sample sonar-project.properties
which assumes the following:
src/components/Foo/Foo.jsx
the main component.src/components/Foo/Foo.spec.jsx
the test file.# Source
sonar.sources=src
# Where to find tests file, also src
sonar.tests=src
# But we get specific here
# We don't 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
# Now specify path of lcov and testlog
sonar.javascript.lcov.reportPaths=coverage/jest/lcov.info
sonar.testExecutionReportPaths=coverage/jest/testlog.xml
Now your test files will also show up.
More information here