jest-runner require "jest-environment-jsdom" without it being listed in its dependencies
See original GitHub issue🐛 Bug Report
Full error:
Package "jest-runner@23.6.0" (via "/Users/mael/Library/Caches/Yarn/v3/npm-jest-runner-23.6.0-3894bd219ffc3f3cb94dc48a4170a2e6f23a5a38/node_modules/jest-runner/build/run_test.js") is trying to require the package "jest-environment-jsdom" (via "jest-environment-jsdom") without it being listed in its dependencies (exit, graceful-fs, jest-config, jest-docblock, jest-haste-map, jest-jasmine2, jest-leak-detector, jest-message-util, jest-runtime, jest-util, jest-worker, source-map-support, throat, jest-runner)
To Reproduce
I’m not sure exactly how envs are specified in Jest; I got the error by running yarn jest
in the create-react-app
repo, which doesn’t have any special kind of configuration.
Expected behavior
No error should be thrown. The environment should by default be already resolved, so that the require
call in jest-runner
would be a noop (I’m not sure where this default configuration is set, but basically it should be testEnvironment ||= require.resolve('jest-environment-jsdom')
rather than testEnvironment ||= 'jest-environment-jsdom'
).
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
pnpm/pnpm - Gitter
I mean that the application itself needs to get those helper modules exposed, even though it has no direct dependency and it has...
Read more >Configuring Jest
If a given module's path matches any of the patterns, it will not be require() -able in the test environment. These pattern strings...
Read more >Jest with TypeScript: TypeError: environment.teardown is ...
It has a dependency on jest@20.0.4 (that should have been under its ... of the test environments do not contain everything required by...
Read more >testing node api with jest
The supertest module is used to mock the Express request to /hikes ... it's recommended to use jest-environment-jsdom-fifteen package as Jest uses a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just adding this here for those who might google their way to this thread:
This can be worked around by installing
jest-environment-jsdom
in the root package of the project (eg.yarn add -D jest-environment-jsdom
).This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.