-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
expect NPM package unusable in browser #7109
Comments
That's odd, we are outputting umd modules for it: https://github.com/facebook/jest/blob/d59a4d33b6aff50df3f2a307d71797a5d0e5f298/scripts/browserBuild.js#L70 Do we do anything else that messes up the transformation? BTW, it works if you bundle up your tests using e.g. browserify, but we should definitely work as a script tag |
Ah, it's rollup/rollup#1646 combined with https://github.com/facebook/jest/blob/d59a4d33b6aff50df3f2a307d71797a5d0e5f298/packages/expect/src/index.js#L389 Since our next release is a major, we should probably go through and remove all |
I have hacked a global Glad to hear you'll fix it, thanks! |
Hello Guys, can i take this issue? Can you provide some guidance about implementation? Change |
Can i take this issue? Can you provide some guidance? Changes to |
I've got a branch with some of the work done, you can work off of that: https://github.com/SimenB/jest/tree/esm-export I think it's just a matter of fixing the tests, and you should be good to go 🙂 |
Ok, i will fix tests and send PR :) |
I should add dynamic imports in |
Do you mean support |
Okay, so I'm not going to remove it. |
@jods4 Im having trouble reproducing this bug, could someone help me in a beginner level, thanks in advance. |
I managed to reproduce it, the 1st slash "/" in the src of the script was the problem for me if anyone is having trouble too. |
Fixed in #7548 (not released) |
Reverted: #7602 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
The
expect
NPM package is not usable in browser, although it has abrowser: build-es5/index.js
field.To Reproduce
Add this to a static page:
It almost works, with the sole exception that the very last line fails:
module.exports = expect
Because there's no global
module
object.Expected behavior
Should not throw and expose a global
expect
object.If you detect that there's no
module
but awindow
instead, doingwindow.expect = expect
makes everything work perfectly.The text was updated successfully, but these errors were encountered: