question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression: "ReferenceError: global is not defined"

See original GitHub issue
  • @testing-library/dom version: 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:22 (7 by maintainers)

github_iconTop GitHub Comments

24reactions
fc1943scommented, Jun 2, 2021

Adding this dev dep solves the error for me (jest 27) "jest-environment-jsdom": "~27.0"

21reactions
sibeliuscommented, May 31, 2021

this is a problem only when running tests with jest 27

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found