-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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 tests are failing when running within a Yarn workspace #4021
Comments
I'm guessing it could have something to do with jestjs/jest#5401? |
Ok, after trying out a few more things, it seems like having jest as a dep. in another workspace causes the issue. It could be some incompatibilities between versions of |
Your app is using react-scripts-ts@2.13.0 which uses jest@20.0.4, but package-a and -b are using jest@22.1.4. If you change your package-a and package-b to use jest@20.0.4, you won't have this error. (I don't think you need the jest-environment-jsdom dependency in package-a or -b -- I think you can just remove those, otherwise they probably need to match, too.) I don't know of a way to use two different versions of jest, possibly with a --nohoist option which is not yet supported by yarn, but will be soon. |
@bradfordlemley yes, that seems to be true. I used the version I saw on the react-scripts-ts repo instead of the I'll give it a shot to see if anything changes. |
Ok, now the cra app tests throw that error but the packages' tests work just fine. |
You probably have some old dependencies hanging around. Delete all the node_modules dirs (cra-workspaces/node_modules, app/cra/node_modules, packages/package-a/node_modules, packages/package-b/node_modules), then run |
Oh, my bad. I tried with I created an issue to ask for a version bump though. Thanks. |
Just to update that after hours of trying, I am able to find a way to resolve this issue: Add this piece of code into your root
|
Thank you @huchenme . |
Looks like this issue has been resolved. Please open a new issue if you continue to experience problems. |
Is this a bug report?
Yes
Did you try recovering your dependencies?
Yes.
Which terms did you search for in User Guide?
yarn workspaces,
jest fails
,yarn jest
,jest env
,dispose is not a function
,jest typeError environment
, etc.Environment
node -v
: 894npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.3.2npm ls react-scripts
(if you haven’t ejected):Then, specify:
Steps to Reproduce
yarn install
at rootapps/cra
and runyarn test
packages/package-a
/packages/package-b
and runyarn run test:cov
Expected Behavior
Tests should run without errors.
Actual Behavior
Some tests are throwing:
Reproducible Demo
See cra-workspaces repo for an example of setup that has this issue.
The text was updated successfully, but these errors were encountered: