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

@nrwl/jest does not support testing library with yarn berry pnp mode #11733

Closed
vlwkaos opened this issue Aug 26, 2022 · 2 comments
Closed

@nrwl/jest does not support testing library with yarn berry pnp mode #11733

vlwkaos opened this issue Aug 26, 2022 · 2 comments

Comments

@vlwkaos
Copy link

vlwkaos commented Aug 26, 2022

Current Behavior

Setting yarn to use version 2>= with Plug n Play as nodeLinker and running nx test fails, possibly due to lack of ESM support from yarn berry's pnp mode.

Check Failure Log for further detail.

Expected Behavior

nx test should not fail with an external error.

Steps to Reproduce

  1. npx create-nx-workspace
  2. Workspace name: test-nrwl-jest
  3. What to create in the new workspace: apps
  4. cd test-nrwl-jest
  5. yarn set version berry
  6. Change nodeLinker config to pnp in .yarnrc.yml
  7. yarn add -D @nrwl/node
  8. yarn add -D @nrwl/jest
  9. yarn nx g @nrwl/node:application test-app
  10. add a test file e.g main.spec.ts to newly created test-app
  11. add a simple test to the test file
describe('test', () => {
  it('should work', () => {
    expect(0).toBe(0);

  })
})

  1. yarn nx test

Failure Logs

  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'resolvedFileName')

      at module.exports (../../.yarn/cache/@nrwl-jest-npm-14.5.10-835c314aa3-79dab015fe.zip/packages/jest/plugins/resolver.ts:85:22)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.248 s
Ran all test suites.

Environment

>  NX   Report complete - copy this into the issue template

   Node : 16.16.0
   OS   : darwin x64
   yarn : 3.2.3

   nx : 14.5.10
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : Not Found
   @nrwl/eslint-plugin-nx : 14.5.10
   @nrwl/express : Not Found
   @nrwl/jest : 14.5.10
   @nrwl/js : Not Found
   @nrwl/linter : 14.5.10
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.5.10
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/workspace : 14.5.10
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

I think this issue is related to #10296, #10414 and #11335.
Maybe making it a dynamic import as per #10414 can fix it.

I might try a similar fix to the above if I have time.

@AgentEnder
Copy link
Member

We are working on addressing support for Yarn, but pnp in particular is likely to still have issues in several places. Yarn berry / pnp support is tracked in #2386, so I'm going to close this out.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

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

No branches or pull requests

2 participants