-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support mock injections usable to mock globalThis value #205
Conversation
very want to merge this |
@iambumblehead look ok for first time implementation, thx! But there are obvious pitfalls with code directly uses globalThis, because 'globalThis.fetch === fetch' returns false after injection. So we have to patch globalThis object. |
Maybe it will become necessary to mock "globalThis" specifically and maybe not. This PR allows one to write unit-tests around fetch and other globals. It also enables importing mock values in creative ways, to alter the way a script might use "globalThis". |
thanks for the approval will merge and publish sometime over the next day or so |
closes #198
@koshic @Swivelgames and/or @tommy-mitchell please review.
Changes here allow esmock to be called this way. esmock adds an 'import' statement at the top of the file, importing the mock-versions of the definitions,
req.js