Skip to content

global is not defined #985

Closed
Closed
@JesusTheHun

Description

@JesusTheHun
  • @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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions