Can't exclude folders from coverage report

We have a nuxt projects with jest installed.

When testing locally we have 42% coverage. However sonar only says 30%. I have be setting one folder as the source at a time to see what happens to the coverage.

For example I have only set ‘pages’ which locally has nearly 90% coverage. However Sonar is reporting only 13%.

Here is our sonar-project.properties file:

sonar.sourceEncoding=UTF-8
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=coverage/test-reporter.xml
sonar.typescript.tsconfigPath=tsconfig.json
sonar.sources=pages
sonar.test.exclusions=pages/__tests__
sonar.coverage.exclusions=dist,types,proto,proto-files,static,coverage,pages/__tests__/,pages/__tests__
sonar.language=js
sonar.tests=**/*.spec.ts
sonar.test.inclusions=**/*.spec.ts
sonar.typescript.lcov.reportPaths=coverage/lcov.info

I feel like I’m missing something obvious but not sure how to see what is being included / excluded by sonar cloud’s coverage.

Hey there

You need to be using glob patterns. For example:

sonar.coverage.exclusions=dist/**/*,proto/**/* and so on.

The documentation on analysis scope gives a pretty thorough, if not lengthy, description of all the ways to adjust analysis scope, as well as an overview of glob patterns at the bottom of the page.

1 Like

Thanks - it is pretty tricky figuring out which params can take globs or not.

Either way adding the above made no difference to the coverage value.

Looking at the output I can see this issue which suggests some tests are being ignored?

INFO: Test execution data ignored for 23 unknown files, including:
/opt/atlassian/pipelines/agent/build/components/__tests__/RegistrationFields.spec.ts
/opt/atlassian/pipelines/agent/build/pages/__tests__/registrationFormP1.spec.ts
/opt/atlassian/pipelines/agent/build/pages/__tests__/registrationFormP2.spec.ts
/opt/atlassian/pipelines/agent/build/pages/__tests__/institutionRegisterButtons.spec.ts
/opt/atlassian/pipelines/agent/build/components/__tests__/LogoItem.spec.ts```