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.

global is not defined

See original GitHub issue

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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JesusTheHuncommented, Jun 21, 2021

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.

0reactions
eps1loncommented, Jun 22, 2021

Sounds like an issue with your test setup. Feel free to re-open once you can reproduce the issue.

Read more comments on GitHub >

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

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