-
-
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
restoreMocks doesn't reset the mocks from the last test if mocking jsdom in a beforeEach #5790
Comments
Is the cause that restoreAllMocks is called in a global |
I moved it to a afterEach in my own project (where we have 900 suites and random failures) and it seems fine. But I don't know why its in beforeEach so I'll wait to hear from someone before I send a patch. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
https://repl.it/@lukeapage/Fails-based-on-order
In the above repl you need to make sure the tests run the files in the right order - one then two. When two fails it goes to the begining, the tests pass and then its difficult to reproduce.
If in one test file you mock jsdom in a beforeEach and in a second file use the jsdom function unmocked, then you end up with the mock function.
I tried to make a test case not using jsdom and it was fine.
Within one file its fine.
If the last test in a file doesn't have a beforeEach adding the mock, its also fine.
e.g. the restoreMocks option is behaving differently to adding jest.restoreAllMocks() in a afterEach
What is the expected behavior?
restoreMocks: true will restore all mocks
Please provide your exact Jest configuration
Run
npx envinfo --preset jest
in your project directory and paste theresults here
See the repl above
The text was updated successfully, but these errors were encountered: