Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stored snapshots can't be found on CI only #7094

Closed
StarpTech opened this issue Oct 3, 2018 · 7 comments
Closed

Stored snapshots can't be found on CI only #7094

StarpTech opened this issue Oct 3, 2018 · 7 comments

Comments

@StarpTech
Copy link

StarpTech commented Oct 3, 2018

πŸ› Bug Report

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.

To Reproduce

https://travis-ci.org/Prettyhtml/prettyhtml/jobs/436540742

Jest version: 23.6.0

Expected behavior

Tests should work as locally because all my snapshots are checked in the source control.

@StarpTech
Copy link
Author

The issue could be identified. The test pattern matched the tests inside the production build and in the test directory πŸ˜„

@SimenB
Copy link
Member

SimenB commented Oct 4, 2018

Is this something jest could have detected and warned about?

@StarpTech
Copy link
Author

StarpTech commented Oct 4, 2018

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.

@joaoeudes7
Copy link

Any news as a correction?

@StarpTech
Copy link
Author

@joaoeudes7 Look at my last comment it was my fault.

@superhawk610
Copy link

superhawk610 commented Jun 20, 2019

To further clarify for anyone else that stumbles on this thread, here's the situation that causes this:

src
 └─ __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!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants