I’m using a Vue CLI-generated project structure and use Jest for unit testing (https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-jest). By default the Jest configuration offers two alternatives where Jest is looking for tests
- inside a dedicated structure
- or inside any subdirectory
I want to use the second approach as the test code is located closer to the production code. This leads to a directory structure like
- production code
- test code
As Sonarqube supports the usage of wildcards in other analysis parameters (https://docs.sonarqube.org/latest/analysis/coverage/) I gave this configuration a try to mark these files as test code and to exclude them from analysis:
The scan fails with
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:184.108.40.2066:sonar (default-cli) on project hello-world: The directory '/var/lib/tomcat8/data/jenkins/jobs/hello-world/jobs/sonar/workspace/gui/**/__tests__/*' does not exist for Maven module [...]. Please check the property sonar.tests -> [Help 1]
Regarding the SonarQube documentation, this seems to be the expected result. The parameter
sonar.tests is defined as “Comma-separated paths to directories containing test source files.”. No word about the option to use wildcards here.
But what would be the correct way to configure the scanner in this scenario?
SonarQube version: 7.9.1