So I am writing unit test using "react-testing-library" on Jest and I have this error:
Test suite failed to run
ReferenceError: global is not defined
at Object.<anonymous> (node_modules/@jest/core/node_modules/graceful-fs/graceful-fs.js:92:1)
at Object.<anonymous> (node_modules/@jest/core/node_modules/expect/build/toThrowMatchers.js:10:24)
at Object.<anonymous> (node_modules/@jest/core/node_modules/expect/build/index.js:35:48)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (node_modules/@jest/core/build/runJest.js:387:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:408:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:261:3)
After I added "jest-environment-jsdom": "^27.0.6"
as a dev dependency, that error went away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With