enzymejs / enzyme

JavaScript Testing utilities for React
https://enzymejs.github.io/enzyme/
MIT License
19.96k stars 2.01k forks source link

[enzyme-adapter-react-16] Attempts to access DOM after jest.afterEach cleanup #2523

Open Whoaa512 opened 3 years ago

Whoaa512 commented 3 years ago

Initially found this issue while migrating to jest-circus and filed an issue there but turns out it's an enzyme bug

Link to repro repo

https://github.com/Whoaa512/jest-circus-each-bug

API

Version

Versions listed in the repo linked above

Adapter

ljharb commented 3 years ago

I'm not sure what you mean, can you elaborate?

ljharb commented 3 years ago

Reading the linked issue - you simply must not "clean up" the window, ever. Modules throughout the graph, including react itself, will have cached window on first require, and if you change that later, they'll still have a reference to the previous value.