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

Fix test retries that contain snapshots #8629

Merged
merged 5 commits into from Jul 4, 2019
Merged

Conversation

@rogeliog
Copy link
Collaborator

rogeliog commented Jul 1, 2019

Summary

This PR is heavily inspired by @palmerj3's PR #8019 and most of the credit goes to him

This should make snapshots play better with retryTimes. I tried to add e2e tests for as much as I could. I don't know if I'm missing some use cases, would love some input on that.

Fixes #7493
Closes #8015

Test plan

Added some e2e tests.

Copy link
Collaborator

thymikee left a comment

Looks good! I left small nits to address

packages/expect/src/types.ts Outdated Show resolved Hide resolved
@SimenB SimenB requested a review from palmerj3 Jul 3, 2019
Copy link
Collaborator

palmerj3 left a comment

Looks great!!

event.test.errors = [];
// Clear any snapshot data that occurred in previous test run
global.expect.clearState();

This comment has been minimized.

Copy link
@jeysal

jeysal Jul 3, 2019

Collaborator

This forces expect to be available, while circus is so far not tightly coupled to it (and in theory built to be used anywhere, the legacy-code directory aside). Can we make it gracefully handle expect/clearState not being available and move it to a separate event handler?

This comment has been minimized.

Copy link
@rogeliog

rogeliog Jul 3, 2019

Author Collaborator

This is a great point, you are right we should find to prevent jest-circus of being coupled with expect.

@rogeliog rogeliog force-pushed the rogeliog:test-retries branch from d1fe537 to 313fb53 Jul 3, 2019
@@ -131,6 +132,8 @@ export const initialize = ({
});
setState({snapshotState, testPath});

addEventHandler(handleSnapshotStateAfterRetry(snapshotState));

This comment has been minimized.

Copy link
@SimenB

SimenB Jul 4, 2019

Collaborator

oooh, I like this! good call

@SimenB
SimenB approved these changes Jul 4, 2019
Copy link
Collaborator

thymikee left a comment

This looks way better than I last saw it :D

@thymikee thymikee merged commit dd3d7b0 into facebook:master Jul 4, 2019
11 checks passed
11 checks passed
ci/circleci: lint-and-typecheck Your tests passed on CircleCI!
Details
ci/circleci: test-browser Your tests passed on CircleCI!
Details
ci/circleci: test-jest-circus Your tests passed on CircleCI!
Details
ci/circleci: test-node-10 Your tests passed on CircleCI!
Details
ci/circleci: test-node-11 Your tests passed on CircleCI!
Details
ci/circleci: test-node-6 Your tests passed on CircleCI!
Details
ci/circleci: test-node-8 Your tests passed on CircleCI!
Details
ci/circleci: test-or-deploy-website Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
facebook.jest #20190703.4 succeeded
Details
aliaksandr-yermalayeu added a commit to aliaksandr-yermalayeu/jest that referenced this pull request Jul 16, 2019
* Fix bug with snapshots and retries

* Update CHANGELOG.md

* Address e2e tests PR comments

* Use correct type for snapshotState

* Simplify implementation and decouple it from expect
This was referenced Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.