jest: [Bug]: Upgrading from 29.6.2 to 29.6.4 breaks the tests
Version
29.6.4
Steps to reproduce
Clone the following repo:
https://github.com/maplibre/maplibre-gl-js
run npm i
run npx jest ./src/ui/map.test.ts
Unit test fail
Expected behavior
The tests should not fail as this wasn’t a major version release and there should not be breaking changes.
Actual behavior
The tests started failing, this can also be observed in our PR which uses dependabot: https://github.com/maplibre/maplibre-gl-js/pull/3042
Additional context
Not sure, I tired to debug the tests and understand why they started failing, but I’m not sure what’s the root cause. Sorry that I can’t do a minimal reproduction, but I wouldn’t know where to start…
Environment
Reproduces on mac, windows, linux.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 4
- Comments: 24 (7 by maintainers)
I have the same issue
Changing
resetAllMocks
torestoreAllMocks
fixed it for me too! Thanks for the tips.Hi guys, I got the same problem after update from
29.6.1
to29.6.3
.In my case it was related to the
resetAllMocks
. I have the following script defined onsetupFilesAfterEnv
which works well in version29.6.1
After updating to
29.6.3
the tests stopped working. First, I took a look at my code and discovered that the tests were broken because the mock functions were not being reset, returning the same value as the previously run tests. So I took a look at the release notes and found that some changes related to mocks were reverted in the version related to this PR https://github.com/jestjs/jest/pull/14429In trial and error I changed the script to the following code and it worked again.
@SimenB I’m studying
jest
under the table because I can’t explain exactly why this happened, but it solved my problem. Maybe this could be a tip on how to reproduce this problem.Unsure if this’ll help anyone but I had an issue updating from
29.6.2
to29.7.0
tracked it back to29.6.3
and this change: https://github.com/jestjs/jest/pull/14366The error was
Forcing the resolution of
jest-util
to29.7.0
and updatingbabel-jest
to the same solved it.