jeudi 19 septembre 2019

How ignore snapshot generated by jest on jest's coverage?

I'm setting some new configurations to jest, I got ignore some files like *.stories.js, but when I use *.js.snap or *.snap, the jest don't work well.

I'm using react-scripts, where the same use jest

So for example, if I only ignore *.stories.js like this below command:

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

------------------------------------------------|----------|----------|----------|----------|-------------------|
File                                            |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------------------------------------|----------|----------|----------|----------|-------------------|
All files                                       |    92.98 |       90 |    96.43 |    94.34 |                   |
 components/atoms/grid                          |      100 |      100 |      100 |      100 |                   |
  Grid.js                                       |      100 |      100 |      100 |      100 |                   |
  index.js                                      |        0 |        0 |        0 |        0 |                   |
 components/atoms/grid/__snapshots__            |        0 |      100 |      100 |        0 |                   |
  Grid.test.js.snap                             |        0 |      100 |      100 |        0 |                 1 |
 components/atoms/grid/components               |      100 |      100 |      100 |      100 |                   |
  Cell.js                                       |      100 |      100 |      100 |      100 |                   |
  index.js                                      |        0 |        0 |        0 |        0 |                   |
 components/atoms/grid/components/__snapshots__ |        0 |      100 |      100 |        0 |                   |
  Cell.test.js.snap                             |        0 |      100 |      100 |        0 |                 1 |
 components/atoms/grid/helpers                  |        0 |        0 |        0 |        0 |                   |
  calcOffset.js                                 |        0 |        0 |        0 |        0 |                   |
  index.js                                      |        0 |        0 |        0 |        0 |                   |
 components/atoms/text                          |      100 |      100 |      100 |      100 |                   |
  Text.js                                       |      100 |      100 |      100 |      100 |                   |
  index.js                                      |        0 |        0 |        0 |        0 |                   |
 components/atoms/text/__snapshots__            |        0 |      100 |      100 |        0 |                   |
  Text.test.js.snap                             |        0 |      100 |      100 |        0 |                 1 |
 helpers                                        |      100 |      100 |      100 |      100 |                   |
  breakpoints.js                                |      100 |      100 |      100 |      100 |                   |
  calcPercent.js                                |      100 |      100 |      100 |      100 |                   |
  index.js                                      |        0 |        0 |        0 |        0 |                   |
 provider                                       |      100 |       50 |      100 |      100 |                   |
  style.js                                      |      100 |       50 |      100 |      100 |                 9 |
 theme                                          |     87.5 |      100 |       50 |      100 |                   |
  GlobalStyle.js                                |      100 |      100 |      100 |      100 |                   |
  colors.js                                     |      100 |      100 |      100 |      100 |                   |
  index.js                                      |    83.33 |      100 |       50 |      100 |                   |
------------------------------------------------|----------|----------|----------|----------|-------------------|

But if I add *.js.snap don't find the other files that doesn't is snap

react-scripts test --coverage --collectCoverageFrom=!src/**/*.stories.js --collectCoverageFrom=!src/**/*.js.snap

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

Aucun commentaire:

Enregistrer un commentaire