Skip to content
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

Not working if Jest is installed by pnpm #5369

Closed
KSXGitHub opened this issue Jan 23, 2018 · 7 comments
Closed

Not working if Jest is installed by pnpm #5369

KSXGitHub opened this issue Jan 23, 2018 · 7 comments

Comments

@KSXGitHub
Copy link

KSXGitHub commented Jan 23, 2018

Do you want to request a feature or report a bug?

Bug

Steps to reprocedure:

  1. Clone this repo
  2. Install pnpm (yarn global add pnpm)
  3. Run pnpm install to install dependencies
  4. Run pnpx jest to run test
  5. Delete node_modules
  6. Run yarn jest

What is the current behavior?

Step 4 fails but step 6 doesn't.

TypeError: environment.setup is not a function

What is the expected behavior?

Step 4 doesn't fail.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Related issue: pnpm/pnpm#1007

UPDATE:

jest doesn't work but jest-cli does.

@KSXGitHub
Copy link
Author

I just discovered that the test will fail if --preserve-symlinks flag is provided

@SimenB
Copy link
Member

SimenB commented Jan 24, 2018

Does this still happen with jest 22? I wonder if it's related to #5294. And maybe #5356.

@KSXGitHub
Copy link
Author

KSXGitHub commented Jan 24, 2018

@SimenB I tried with v22.0.4 and v22.1.4, jest and jest-cli.

jest-cli doesn't always work, it just fails less frequently.

@josh-stevens
Copy link

josh-stevens commented Apr 4, 2018

Adding my +1 to this. I've loved Jest for testing both React and Node, but our team recently switched to PNPM. The gains from PNPM are too great to go back. I've tried a few things but nothing seems to be working. Replacing jest with jest-cli had no effect. Installing with --shamefully-flatten didn't work either. Oddly enough I'm not seeing the environment.setup is not a function

The first thing I see is Cannot find module 'jest-environment-jsdom'. Installing that dependency and trying to run jest gives Unexpected token import as soon as my test tries to run. So it looks like jest isn't loading its dependencies correctly to work with pnpm and is tripping up on some babel related stuff.

EDIT: I got it working by adding the transform as seen in the issue creator's Jest config. I'm not sure why that's needed for pnpm but not for regular npm. It still requires me to explicitly add jest-environment-jsdom as a dependency in my project.

@aleclarson
Copy link
Contributor

aleclarson commented Sep 16, 2018

Possibly related: facebook/metro#231

They both use jest-haste-map.

@chapmanjacobd
Copy link

I think this issue can be closed?

pnpm/pnpm#1007

@thymikee thymikee closed this as completed Sep 1, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants