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
I don't think so, since globals are global. If you td.replace(globalThis, 'doodleDart'), you'll be replacing it until you td.reset() for anyone who'll reference it. Rather than get more clever with a mocking tool at this point, I'd encourage you to create a seam (some unit of code that serves as indirection between the thing being tested and the global) that you can safely fake out under strict test control instead.
My use case is mocking something like Date.now().
I could pass it as a dependency in all calls down, yes.
If I don't, I could mock the global. But in concurrent tests it could affect each other.
I would want to mock a global variable but only in a selected ESM. Is it possible?
(instead of mocking a module export)
The text was updated successfully, but these errors were encountered: