-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest.retryTimes() gets confused with snapshots #7493
Comments
/cc @palmerj3 |
I've encountered same issue, apparently |
I'll take a look! Thanks for reporting. |
So I took a look at this just now. When I test this against jest master there doesn't appear to be a problem. Using the test suite attached in the description it initially failed to match the included snapshot. But updating the snapshot (-u) or clearing out the snapshots folder results in a snapshot that looks correct:
I have a feeling I'm missing some context here though. Please let me know if so. If you could provide a reproducible failure based on jest master that would be really helpful. |
Also when the test suite passes the exit code is 0, not 1, for me. |
The bug is a couple of months old, I wonder if it has been addressed already. I'll retry it. |
do you guys know the status of this? happy to take a stab if it's up for grabs |
with a test like this: // this should return 1, but sometimes, since it's flaky, it returns 2
function functionToTest() {
return 1;
}
describe('foo', () => {
it('works', () => {
const result = functionToTest()
expect(2).toMatchSnapshot('a');
});
}); the first time it runs, it matches the snapshot. Now, if we substitute
another way to reproduce a similar behavior is: describe('foo', () => {
it('works', () => {
expect(1).toMatchSnapshot();
throw new Error();
});
}); and suppose retryTimes is set to 3, the snapshot will look like:
I am pretty sure this is not the expected behavior running on 24.1, couldn't try this on master |
Closing for now. If you create a repo that reproduces this problem on the latest version of jest I'll take another look. |
Seems to reproduce on jest 24.1from the last report? @itajaja if possible, you could put together a failing e2e test in this repo and send a PR with it? Including a fix would of course be awesome, but a failing test is the best reproduction there is :) |
will do, but literally this: describe('foo', () => {
it('works', () => {
expect(1).toMatchSnapshot();
throw new Error();
});
}); will create these snapshots
This is a problem between circus and snapshot, because snapshot always increments the counter before doing the match, so even looking at the code statically, this is apparent (this line specifically tells it all). |
I'll take a look again today. But a repo with reproducible steps is best for these things moving forward and that is what is said in the issue template. |
it's really not a failing test, but it's enough to see the misbehavior clearly |
Thank you |
can we reopen this :P |
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. |
π Bug Report
Each retry of a test with a snapshot is identified as a different snapshot. In addition a snapshot test that eventually passes exits as a test failure (exit code 1).
To Reproduce
jest-bug.zip
Snapshot
Expected behavior
Snapshot retries should maintain the same name and should exit with 0 if it eventually passed
Link to repl or repo (highly encouraged)
jest-bug.zip
Run
npx envinfo --preset jest
The text was updated successfully, but these errors were encountered: