You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
problem: jest test files are running individually in their own scope, though when to-be-tested-modules files are being loaded with esm the scope is being shared.
Ah yes, this would make sense because we are sharing the context 😋
It can be adjusted to be individualized though.
Update:
Ok so in digging into this a little more the issue isn't about scopes or contexts it's about shared Module._cache data. The esm loader will share cache data per identically configured instance. I can see now though that each instance should have their own module cache.
Update:
Ok so digging into it even more we don't share Module._cache between instances explicitly it's the fact that our internal Module._cache is initialized with that of CJS (the real Module._cache). Jest must not be clearing the real Module._cache which is why ours is allowed to persist.
Deferring to the builtin CJS cache is a good thing that helps with CJS interop. I don't want to remove that so instead I can detect if esm is running in jest and start fresh in that case only. When running in jest there is a global free variable jest that I can detect.
node v10.5.0
esm: v3.0.62
jest: v23.3.0
problem: jest test files are running individually in their own scope, though when to-be-tested-modules files are being loaded with esm the scope is being shared.
repro:
https://github.com/dnalborczyk/esm-jest-repro/tree/jest-scope
edit: added repro
The text was updated successfully, but these errors were encountered: