-
-
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 doesn’t respect Node resolution when looking for the CLI #5294
Comments
This was introduced back in 39356eb |
Wow, history. I think this makes sense if the launched CLI is global (outside of CWD) but the found CLI is local. However it doesn't make sense to me if both of them are inside of CWD. |
I wonder if using https://www.npmjs.com/package/import-local would fix it. |
See #5304. |
We have the same issue with If people install a Should we fix this? |
I just started a new CRA and ran into the missing jest-cli issue and "TypeError: environment.setup is not a function" (also noob to React)
Turns out, I had to remove
|
CRA comes with jest built in. You need to remove it from your own package.json. See facebook/create-react-app#1795 and the many linked discussions within |
Yeah, that's not the optimal answer. I read facebook/create-react-app#1795, and the many linked discussions. Turns out that This is a virgin CRA app, nothing of note added but the packages. Following the advice of "removing Jest," which wasn't in my packages at any rate...
Yields:
I install a few packages to minimally get past errors resulting in:
and a test that should properly fail
|
You can't have |
To folks commenting here: Jest tracker isn't the best place to report issues about CRA :-) This way we don't hear about them and people spend weeks with broken setups while we're completely unaware. Please file an issue in CRA itself. |
I published https://github.com/facebook/create-react-app/releases/tag/v1.1.3 |
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. |
This is related to #5119 (comment).
Our
react-scripts
package from Create React App depends onjest
and runs it using the Node API. Sojest
is generally a dependency.However, people often install top-level
jest
in their project (mostly because they don’t know it won’t work), and this breaks their setup with obscure errors like #5119. Their tree looks something like:Ideally, top-level
jest
installations shouldn't break the copy ofjest
inreact-scripts
. This is a general assumption that typically holds true in the Node ecosystem: different versions of the same subdependency can coexist in different parts of the tree, and not break each other as long as you don’t mix their state.In the case of Jest, it breaks because Jest uses
<process.cwd()>
/
node_modules/jest-cli
as the location of the CLI. Since in our project,process.cwd()
is its root, Jest 22 “finds”jest-cli
from Jest 20 and mistakingly uses it instead of its own copy ofjest-cli
:I don’t know if this is intentional. Maybe this has to do with multi-project runner? Regardless, it would be nice if Jest either supported this, or failed with a clear message when Node API of one version of Jest resolves to the CLI code of another version of Jest.
The text was updated successfully, but these errors were encountered: