question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to exclude some files and folders from coverage report?

See original GitHub issue

I am trying to exclude some JS files from coverage report. I have already added this to package.json

"jest": {
    "testPathIgnorePatterns" : ["<rootDir>/node_modules/", "<rootDir>/path/to/dir/" ],
    "testResultsProcessor": "./node_modules/jest-junit-reporter"
  }

Unfortunately files from those dir still appear when I run CI=true npm test -- --coverage

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:21
  • Comments:34 (12 by maintainers)

github_iconTop GitHub Comments

77reactions
gaearoncommented, Feb 9, 2017

This is commonly requested & we should support this.

52reactions
robcaldecottcommented, Jan 30, 2017

OK, I needed to ignore all *.stories.js files and you can do this by overriding the value for the Jest collectCoverageFrom option, which can be passed on the command-line via a custom npm test command. Note that collectCoverageFrom expects an array so to pass multiple values you specify the option multiple times.

For example:

npm test -- --coverage --collectCoverageFrom=src/**/*.js --collectCoverageFrom=!src/**/*.stories.js

Notice the exclamation point (can I still call it a pling or does that betray my age?) to exclude a pattern.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible exclude test directories from coverage.py reports?
Create .coveragerc file in your project root folder, and include the following: ... [run] omit = # ignore all test cases in tests/...
Read more >
How to exclude some files and folders from coverage report in ...
In this simple tutorial, we are going to look at how to ignore or exclude some files or folders when testing in React...
Read more >
Excluding code from coverage.py - Read the Docs
Coverage.py identifies exclusions by matching lines against a list of regular expressions. Using configuration files or the coverage API, you can add to...
Read more >
How to exclude the file from a coverage report - FAQ - Aldec, Inc
In order to exclude a file from the coverage report, the -cc_exclude switch should be used with the asim command. ... We use...
Read more >
How to Use a File to Exclude Files From Code Coverage
You can set coverage exclusions in the SonarCloud UI. · You can also add sonar.coverage.exclusions as an analysis parameter added to your scanner ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found