global is not defined
See original GitHub issue@testing-library/dom
version: 7.31.2- Testing Framework and version: jest@27.0.4, @testing-library/react@11.2.7
- DOM Environment: @testing-library/jest-dom@5.14.1
Running Chrome
What you did:
I tried to use rtl in a vitejs project. This builder uses esbuild, which is a lot more closed to the ECMAScript spec and therefore is more strict.
What happened:
Uncaught ReferenceError: global is not defined at node_modules/@testing-library/dom/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js (AsymmetricMatcher.js:10)
Referencing this line of code : var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
Problem description:
While rtl is supposed to be used by nodejs, the package is by default compiled by esbuild and send to the browser, leading to this error.
Suggested solution:
Despite being unrelated to RTL directly, it would be very convenient if you could simply add a check to make sure global
exists before going further.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Uncaught ReferenceError: global is not defined #2141 - GitHub
ncaught ReferenceError : global is not defined at Object../node_modules/buffer/index.js (index.js:43) at webpack_require (bootstrap:76)
Read more >How to fix the ReferenceError: global is not defined error in ...
That sound simple enough to fix, just create a vite.config.[js/ts] file, add it to your SvelteKit project and define global right? // vite....
Read more >Angular 7: Uncaught ReferenceError: global is not defined ...
When I googled it everyone says to add this (window as any).global = window; to pollyfills.ts I have done this and I still...
Read more >index.js:43 uncaught referenceerror: global is not defined
I had a similar problem few weeks ago, and I solve it when I change few setts in polyfills.ts now It look like:....
Read more >Node.js – Angular 7: Uncaught ReferenceError: global is not ...
Node.js – Angular 7: Uncaught ReferenceError: global is not defined when adding package ... When I googled it everyone says to add this...
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 Free
Top 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
I’ve created a simple vitejs project with a storybook and some tests, but the error doesn’t show up. I will try to get a repro but it will probably take a bit of time.
Sounds like an issue with your test setup. Feel free to re-open once you can reproduce the issue.