-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Closed
Copy link
Description
🐛 Bug Report
Jest fails tests with the following error as soon as some imported/required file defines a constant called "global".
SyntaxError: Identifier 'global' has already been declared
See https://github.com/stimberm/reproduce-jest-global-collision for an example.
Renaming the constant is a workaround, as is using var
instead of const
, but that is not feasible for dependencies. Specifically, the latest release of monaco-editor contains a constant called "global" and can therefore not be included in a jest test.
To Reproduce
Have a test require a file that defines a const global = ...;
Expected behavior
The test should run successfully.
Link to repl or repo (highly encouraged)
https://github.com/stimberm/reproduce-jest-global-collision
This stackoverflow question seems to be about the same issue.
envinfo
% npx envinfo --preset jest
npx: installed 1 in 1.366s
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Binaries:
Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
Yarn: 1.22.5 - ~/.nvm/versions/node/v12.18.3/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.18.3/bin/npm
npmPackages:
jest: ^26.4.2 => 26.4.2