expect NPM package unusable in browser
See original GitHub issueš Bug Report
The expect
NPM package is not usable in browser, although it has a browser: build-es5/index.js
field.
To Reproduce
Add this to a static page:
<script src="/node_modules/expect/build-es5/index.js"></script>
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 a window
instead, doing window.expect = expect
makes everything work perfectly.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
expect - npm
This package exports the `expect` function used in [Jest](https://jestjs.io/). ... Start using expect in your project by running `npm i expect`.
Read more >npm not working - "read ECONNRESET" - Stack Overflow
I'd been trying to get past this off and on for months. I had been just disabling VPN, grabbing packages, then logging back...
Read more >Top 10 Most Common Node.js Developer Mistakes - Toptal
JavaScript in Node.js (just like in the browser) provides a single ... by a package to do something asynchronously is designed to expect...
Read more >browser-error-classes - npm Package Health Analysis - Snyk
The npm package browser-error-classes was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as...
Read more >Installing with NPM - Kendo UI for jQuery
The scripts in the NPM package are not usable in the browser. To work around this issue, use a bundler such as WebPack....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 š
Ah, itās https://github.com/rollup/rollup/issues/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
module.exports
usage in favor ofexport default
. It will force people usingrequire
to do.default
, but hopefully itās not too big of a deal