jest-circus beforeEach/afterEach bug
Found this weird bug while migrating to jest-circus ahead of jest v27
I've added a minimal repro case, run yarn test
to see the failing test
Move the wrapWithDOM
function outside the describe block and the test passes
Relevant jest issue: jestjs/jest#11552
update
The root of this failure is actually due to react trying to access the global.window
after it's cleaned up in the afterEach from wrapWithDOM
.
I believe this bug actually lies in enzyme's react 16 adapter due to how to tries to get references to the Lazy tags.
I was able to workaround by wrapping the contents of my afterEach in a setTimeout so the cleanup happens after the React-dom access global.window