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

Cypress e2e does not work with Yarn berry (pnp) #19652

Closed
1 of 4 tasks
unrealsolver opened this issue Oct 17, 2023 · 3 comments
Closed
1 of 4 tasks

Cypress e2e does not work with Yarn berry (pnp) #19652

unrealsolver opened this issue Oct 17, 2023 · 3 comments
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@unrealsolver
Copy link
Contributor

Current Behavior

****@***** ~/d/n/****frontend > yarn nx e2e app-e2e -v

> nx run app-e2e:e2e -v

  ➜  Local:   http://localhost:3000/
  ➜  Network: http://192.168.0.7:3000/
  ➜  Network: http://10.0.85.1:3000/
  ➜  Network: http://172.22.0.1:3000/
  ➜  Network: http://172.23.0.1:3000/
  ➜  Network: http://10.251.0.130:3000/
Your configFile is invalid: /home/***/dev/n***/***frontend/packages/app-e2e/cypress.config.ts

It threw an error when required, check the stack trace below:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/***/dev/***/***frontend/packages/app-e2e/cypress.config.ts
    at new NodeError (node:internal/errors:372:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:76:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:118:38)
    at defaultLoad (node:internal/modules/esm/load:21:20)
    at load$1 (file:///home/***/dev/***/***frontend/.pnp.loader.mjs:1456:12)
    at ESMLoader.load (node:internal/modules/esm/loader:407:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadFile (/home/***/.cache/Cypress/13.2.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:106:14)
    at async EventEmitter.<anonymous> (/home/***/.cache/Cypress/13.2.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:32)

Expected Behavior

Yarn (non-pnp) or npm results:

***@*** ~/d/t/myapp> yarn nx e2e myapp-e2e

> nx run myapp-e2e:e2e

  ➜  Local:   http://localhost:4200/
================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.3.1                                                                         │
  │ Browser:        Electron 114 (headless)                                                        │
  │ Node Version:   v16.15.1 (/home/***/.local/share/nvm/v16.15.1/bin/node)                     │
  │ Specs:          1 found (app.cy.ts)                                                            │
  │ Searched:       src/**/*.cy.{js,jsx,ts,tsx}                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  app.cy.ts
....

GitHub Repo

No response

Steps to Reproduce

yarn dlx create-nx-workspace@latest myapp
# Use React / Vite / Cypress. Other options for reference: regular monorepo, CSS, no caching
corepack enable
yarn set version stable
yarn config set nodeLinker pnp
yarn
yarn nx e2e myapp-e2e

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.15.1
   OS     : linux-x64
   yarn   : 3.6.4

   nx                 : 16.10.0
   @nx/js             : 16.10.0
   @nx/linter         : 16.10.0
   @nx/workspace      : 16.10.0
   @nx/cypress        : 16.10.0
   @nx/eslint-plugin  : 16.10.0
   @nx/react          : 16.10.0
   @nx/vite           : 16.10.0
   typescript         : 5.1.6


### Failure Logs

```shell
See actual/expected behavior.

Package Manager Version

[email protected] pnp-enabled

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

This is the most probably cypress/e2e executor issue. Yarn pnp uses different module resolution and probably the executor is not aware of it.

@FrozenPandaz FrozenPandaz added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Oct 19, 2023
@unrealsolver
Copy link
Contributor Author

Nx v17 & Yarn v4 - no changes in behavior.

@leosvelperez
Copy link
Member

Thanks for reporting this!

This is an issue with Cypress that you can reproduce on a project without Nx. There are multiple issues on the Cypress repo about Yarn PnP. I suggest you follow those for a resolution. To point a few relevant to your issue:

cypress-io/cypress#27450
cypress-io/cypress#22747 (comment)
cypress-io/cypress#25958

I'm closing this since the issue is not caused by Nx. Please follow the relevant issues in the Cypress repo.

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 Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants