Coverage exclusion for test files not working


I was following this guide to set up my coverage reports: Narrowing the Focus | SonarQube Docs

My repo uses a modern style where test files are intermingled with source files, so I ended up with something like the suggestion from the guide:

# Define the same root directory for sources and tests
 sonar.sources = src/
 sonar.tests = src/

 # Include test subdirectories in test scope
 sonar.test.inclusions = src/**/test/**/*

 # Exclude test subdirectories from source scope
 sonar.exclusions = src/**/test/**/*

However, sonar keeps asking for coverage for my .spec.ts files.

I have tried several configurations, including sonar.coverage.exclusions but it is always asking me to cover my spec files.

example folder structure
- libs
  - some_lib
    - __test__
         - index.spec.ts
    - index.ts
## Define the same directory for sources and tests
## Include in test scope: test+mock files/subdirectories
## Exclude from source scope: test+mock files/subdirectories, generated libs
## Exclude from coverage: test+mock files/subdirectories


Welcome to the community!

This isn’t a recognized pattern. You’ll need to actually spell this out, comma-delimited:



Thanks, this works.

I thought I confirmed glob patterns to be working. It would be great if the docs could be more clear on this, i.e. where and which patterns work.


This page is pretty specific:

The patterns are defined using the following wildcards:

  • * - Match zero or more characters
  • ** - Match zero or more directories
  • ? - Match a single character

Were you looking some place else?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.