Regression: "ReferenceError: global is not defined"
See original GitHub issue@testing-library/domversion: 7.22.6- Testing Framework and version: QUnit 2.11.0
- DOM Environment: Chrome 84.0.4147.135 (via Testem)
Relevant code or config:
import { screen } from "@testing-library/dom";
What you did:
I ran my tests: ember test --server.
What happened:
Tests couldn’t be executed, the following error was thrown:
ReferenceError: global is not defined
at Object../node_modules/pretty-format/build/plugins/AsymmetricMatcher.js (test-support.js:37305)
at __webpack_require__ (test-support.js:18993)
at Object../node_modules/pretty-format/build/index.js (test-support.js:36889)
at __webpack_require__ (test-support.js:18993)
at Module../node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js (test-support.js:19861)
at __webpack_require__ (test-support.js:18993)
at Module.callback (test-support.js:19106)
at Module.exports (vendor.js:118)
at Module._reify (vendor.js:155)
at Module.reify (vendor.js:142)
Reproduction:
Problem description:
@testing-library/dom 7.22.3 was working fine.
@testing-library/dom 7.22.6 doesn’t work.
Suggested solution:
I can see there was a bump of pretty-format between 7.22.3 and 7.22.6: https://github.com/testing-library/dom-testing-library/commit/9cbc4280d4eceddc5511c21114455f73cd31d196, perhaps it’s the culprit.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:22 (7 by maintainers)
Top Results From Across the Web
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?...
Read more >global is not defined react - You.com | The AI Search Engine ...
I am getting this error: Uncaught ReferenceError: React is not defined But I can access the React object in browser console I also...
Read more >Uncaught ReferenceError: global is not defined - YouTube
Uncaught ReferenceError : global is not defined at node_modules/@walletconnect/socket-transport/dist/esm/index.jscreate a n ew filw named ...
Read more >BSON npm package does not work when using as a ESM
NODE-3451Performance-Regression - Find/Create is significantly slower in ... Uncaught (in promise) ReferenceError: global is not defined
Read more >Uncaught ReferenceError: global is not defined - Stack Overflow
This possible duplicate of this. The global object is not available. Possible solution to change it to window object.
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

Adding this dev dep solves the error for me (jest 27)
"jest-environment-jsdom": "~27.0"this is a problem only when running tests with jest 27