# Sonar Ignoring test coverage of test runner files

**URL:** <https://community.sonarsource.com/t/sonar-ignoring-test-coverage-of-test-runner-files/26491>\
**Category:** SonarQube Server / Community Build\
**Tags:** javascript, sonarqube, coverage\
**Created:** [June 17, 2020, 12:17am UTC](https://community.sonarsource.com/t/sonar-ignoring-test-coverage-of-test-runner-files/26491 "2020-06-17T00:17:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marchaase](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/marchaase/32/12547_2.png) [@marchaase](https://community.sonarsource.com/u/marchaase)\
**Post date:** [June 17, 2020, 12:17am UTC](https://community.sonarsource.com/t/sonar-ignoring-test-coverage-of-test-runner-files/26491/1 "2020-06-17T00:17:35Z")

</div>

Using SonarQube 8.3.1.34397 and sonar-scanner-4.3.0.2102-linux

I am having trouble getting SonarQube to ignore files for test coverage. I have a JS repository utilizing Jest for test coverage metrics and the test runners are in a file next to the .js file with a name of .test.js. For example functions.js has tests in a file next to it in functions.test.js. SonarQube finds all of the .js files and treats them as sources files and reports no coverage on the .test.js files.

I have Jest outputting lcov reports and point SonarQube to the lcov.info file:

```auto
sonar.javascript.lcov.reportPaths=./test-js/coverage/lcov.info

```

I have sources set as:

```auto
sonar.sources=.
sonar.exclusions= **/node_modules/** /*, \
    **/external/** /*, \
    ./test-js/**/*.test.js, \
    ./test-js/jest.config.js, \

```

I have tests set as:

```auto
sonar.tests=.
sonar.test.inclusions= ./test-js/**/*.test.js, \
    ./test-js/jest.config.js, \

```

I have also tried adding:

```auto
sonar.coverage.exclusions=./test-js/**/*.test.js, \
    ./test-js/jest.config.js, \

```

But nothing I’ve tried seems to work. I’ve tried all various combinations of the above and nothing seems make SonarQube ignore the .test.js files.

Anybody have any ideas?

---

<div class="post-metadata">

**Author:** ![marchaase](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/marchaase/32/12547_2.png) [@marchaase](https://community.sonarsource.com/u/marchaase)\
**Post date:** [June 17, 2020, 1:16am UTC](https://community.sonarsource.com/t/sonar-ignoring-test-coverage-of-test-runner-files/26491/2 "2020-06-17T01:16:23Z")

</div>

I think I may have found my issue - it didn’t like the ‘./’ prefix on those paths…

I was able to get it working with this config:

```auto
# where source files are
sonar.sources=.
sonar.exclusions= \
    **/external/** /*, \

# files to ignore for coverage
sonar.coverage.exclusions= \
    test-js/**/*.test.js, \
    test-js/jest.config.js, \

# files to get coverage information
sonar.javascript.lcov.reportPaths=test-js/coverage/lcov.info

```
