10

See the demo app by doing npm run test:2 https://github.com/adamchenwei/jest-playground.git

You will see the App.js is 100% covered, and it only really has a snapshot.

Are there ways we can tell Jest to ignore snapshot as coverage evidence? Or its what expected?

I haven't been able to find any answers online or even questions been asked, I suspect its either I am asking the wrong question or people consider 100% coverage snapshot as normal, while I feel its render coverage report meaningless in a sense that it only test the template matching from the previous component.

ey dee ey em
  • 7,991
  • 14
  • 65
  • 121

2 Answers2

1
"jest": {
    "coveragePathIgnorePatterns": [
        ".*__snapshots__/.*"
    ],
    ...
},
fransoudelaar
  • 426
  • 4
  • 4
-3

It's pretty easy, you need to remove the --coverage flag and set collectCoverage inside your package.json. This issue seem to occur just with the CLI flag and not within the configuration way which is already reported by #6859. Look at the following configuration:

{
    // ...
    "collectCoverage": true,
    "collectCoverageFrom": ["**/*.tsx?"],
    // ...
}
Jan Biasi
  • 187
  • 1
  • 5
  • this settings doesn't ignore the snapshot tests. The question was how not to consider snapshots when generating the tests as a snapshot can increase the test coverage but it doesn't test anything and it doesn't make sure your code works. – Julius Koronci Feb 08 '19 at 08:46