Snapshots can't be found on CI even when snapshots are checked in the source control.
โ Attributes
expect(value).toMatchSnapshot()
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.
https://travis-ci.org/Prettyhtml/prettyhtml/jobs/436540742
Jest version: 23.6.0
Tests should work as locally because all my snapshots are checked in the source control.
The issue could be identified. The test pattern matched the tests inside the production build and in the test directory :smile:
Is this something jest could have detected and warned about?
I don't think so because the directory structure isn't fixed. We could print a warning when someone is trying to run snapshot tests in a directory like dist, build which won't usually contain fixtures.
Any news as a correction?
@joaoeudes7 Look at my last comment it was my fault.
To further clarify for anyone else that stumbles on this thread, here's the situation that causes this:
โโ __tests__
โโ foo.test.js // <- you want to run these
โโ bar.test.js // <-
โโ __snapshots__
โโ foo.test.js.snap
โโ bar.test.js.snap
dist
โโ __tests__
โโ foo.test.js // <- CI is also running these
โโ bar.test.js // <- (though they have no snapshots)
To debug this, double-check your jest.config.js and make sure you've correctly configured the testPathIgnorePatterns to include /dist/ or something similar.
Hope this helps!
Most helpful comment
To further clarify for anyone else that stumbles on this thread, here's the situation that causes this:
To debug this, double-check your
jest.config.jsand make sure you've correctly configured thetestPathIgnorePatternsto include/dist/or something similar.Hope this helps!