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.

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

github_iconTop GitHub Comments

1reaction
imsnifcommented, Nov 29, 2018

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).

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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-environment-jsdom
Fast, reliable, and secure dependency management.
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 >

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