-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jest-runner require "jest-environment-jsdom" without it being listed in its dependencies #7064
Comments
I'm guessing this is a PnP thing? String comes from here: https://github.com/facebook/jest/blob/f8efff95431dd079abf8ae02b8e541e3019d211b/packages/jest-config/src/Defaults.js#L66 How will this work with people doing |
The resolution should happen here: https://github.com/facebook/jest/blob/f8efff95431dd079abf8ae02b8e541e3019d211b/packages/jest-config/src/utils.js#L105-L142 Ideas on how to make that better/safer/saner? We've had issues with pnpm as well with the environment EDIT: It should be normalized during startup actually, not sure why it's not enough: https://github.com/facebook/jest/blob/f8efff95431dd079abf8ae02b8e541e3019d211b/packages/jest-config/src/normalize.js#L373-L375 |
Last comment, but this might be related: #5913 and https://github.com/facebook/create-react-app/blob/72fe2df6fb014db5e18bed49cf19aab30589e943/packages/react-scripts/scripts/test.js#L61-L113 |
Not great :/ Something that could be interesting would be to use a const PnpWebpackPlugin = require(`pnp-webpack-plugin`);
module.exports = {
resolve: {
plugins: [
PnpWebpackPlugin,
],
},
resolveLoader: {
plugins: [
PnpWebpackPlugin.moduleLoader(module),
],
},
}; |
Just adding this here for those who might google their way to this thread: This can be worked around by installing |
Specifying an explicit edit: Please see #7476 |
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. |
🐛 Bug Report
Full error:
To Reproduce
I'm not sure exactly how envs are specified in Jest; I got the error by running
yarn jest
in thecreate-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 injest-runner
would be a noop (I'm not sure where this default configuration is set, but basically it should betestEnvironment ||= require.resolve('jest-environment-jsdom')
rather thantestEnvironment ||= 'jest-environment-jsdom'
).The text was updated successfully, but these errors were encountered: