SonarQube 9.7.0.61563
Sonar dotnet scanner: latest
I am using the dotnet scanner to scan a solution containing lots of projects. One of those projects (WebsiteHost.csproj) contains both C# code and also a react javascript application (in Typescript) in a subfolder called ClientApp/src
.
When scanned, only the Typescript code files are detected (eg. /builds/rocket/Boost/WebsiteHost/ClientApp/src/components/Alert.tsx
), but the Typescript test file is not detected (eg. /builds/rocket/Boost/WebsiteHost/ClientApp/src/components/Alert.spec.tsx
). I can see this in the scanned code folder in SonarQube.
The scanner shows me this output for this project:
INFO: Indexing files of module 'WebsiteHost'
INFO: Base dir: /builds/rocket/boost/src/WebsiteHost
INFO: Source paths: Configure.AppHost.cs, Controllers/ErrorController.cs, Control...
INFO: Excluded sources: **/src/*UnitTests/**/*, **/src/*IntegrationTests/**/*, **/src/*UITests/**/*, **/src/TestResults/**/*, **/src/WebsiteHost/wwwroot/**/*, **/src/WebsiteHost/ClientApp/public/mockServiceWorker.js, **/src/WebsiteHost/ClientApp/src/**/*.spec.ts*, **/src/WebsiteHost/ClientApp/node_modules/**/*, **/src/*UnitTests/**/*, **/src/*IntegrationTests/**/*, **/src/*UITests/**/*, **/src/WebsiteHost/ClientApp/src/**/*.spec.ts*, **/src/WebsiteHost.UITests/**/*.cy.ts*
INFO: Included tests: **/src/*UnitTests/**/*, **/src/*IntegrationTests/**/*, **/src/*UITests/**/*, **/src/WebsiteHost/ClientApp/src/**/*.spec.ts*, **/src/WebsiteHost.UITests/**/*.cy.ts*
INFO: Excluded sources for coverage: **/src/*UnitTests/**/*, **/src/*IntegrationTests/**/*, **/src/*UITests/**/*, **/src/External.StubServices/**/*, **/src/*Testing.Common/**/*, **/src/**/Configure.AppHost.cs, **/src/**/Program.cs, **/src/Common/Annotations.cs, **/src/Common/Null*.cs, **/src/Common/*Exception.cs, **/src/Application.Interfaces/Resources/*.cs, **/src/Infrastructure.Api.Interfaces/ServiceOperations/**/*.cs, **/src/Infrastructure.Common/Recording/*.cs, **/src/Infrastructure.Storage*/*sitory.cs, **/src/WebsiteHost/ClientApp/src/**/*.spec.ts*, **/src/WebsiteHost/ClientApp/src/**/*.stories.ts*, **/src/WebsiteHost/ClientApp/coverage/**/*, **/src/WebsiteHost/ClientApp/public/**/*, **/src/WebsiteHost/ClientApp/tools/**/*, **/src/WebsiteHost/ClientApp/**/*.config.js
This seems to be be missing the output for Test paths
property, even though, as you can see, we have included this path (**/src/WebsiteHost/ClientApp/src/**/*.spec.ts*
) in the sonar.test.inclusions
variable, and excluded it for the sonar.exclusions
code property.
Then later in the scanner, when I try to upload the test execution report, that references these *.spec.tsx
files, I see this error:
INFO: Sensor Generic Test Executions Report
INFO: Parsing /builds/rocket/boost/src/TestResults/react/sonar-generic.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 50 unknown files, including:
/builds/rocket/boost/src/WebsiteHost/ClientApp/src/pages/users/LoginPage.spec.tsx
/builds/rocket/boost/src/WebsiteHost/ClientApp/src/pages/cars/new/components/CarForm/CarForm.spec.tsx
/builds/rocket/boost/src/WebsiteHost/ClientApp/src/pages/users/RegisterPage.spec.tsx
/builds/rocket/boost/src/WebsiteHost/ClientApp/src/pages/users/ResetPasswordPage.spec.tsx
/builds/rocket/boost/src/WebsiteHost/ClientApp/src/validators/password-strength.spec.ts
I am not certain this is the evidence I need to narrow the problem down, but the result is that my TypeScript tests are not being reported in the “Unit test” metric.
What do I have to do to fix this?