Enable support for Cypress tests that rely on workspace packages
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cypress, github-actions, javascript
Direzione di ricerca
Inizia con .github/workflows/web-e2e-deployed-environments.yml e packages/e2e/cypress.config.ts, quindi riproduci il fallimento usando il workflow pnpm workspace mostrato. Traccia il modo in cui la GitHub Action invoca Cypress e il modo in cui il webpack preprocessor risolve @repo/mock/rules. Il lavoro è completato quando gli import dei pacchetti del workspace vengono risolti nell'action, oppure quando una configurazione documentata li abilita in modo affidabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The GitHub Action fails to run Cypress tests in a pnpm monorepo workspace with the following error:
Error: Webpack Compilation Error
Module not found: Error: Can't resolve '@repo/mock/rules' in /home/runner/work/monorepo/monorepo/packages/e2e/cypress/constants'
Environment
- cypress-io/github-action: v6
- Cypress: v14.2.0
- Package manager: pnpm
- Project structure: Monorepo with workspace packages
- OS: Ubuntu 22.04 (GitHub Action runner)
Project Structure
/monorepo
├── .github
│ └── workflows
│ └── web-e2e-deployed-environments.yml # GitHub Actions workflow file
├── packages
│ ├── mock # Mock package with KYC rules and scenarios
│ │ ├── package.json # Contains exports configuration
│ │ ├── src
│ │ │ └── handlers
│ │ │ └── kyc
│ │ │ ├── rules.ts # Exports RULES and SSNS used in tests
│ │ │ └── scenarios.ts # KYC mock scenarios
│ │ └── dist # Built JavaScript files
│ │
│ └── e2e # E2E test package using Cypress
│ │ ├── package.json
│ │ ├── cypress.config.ts
│ │ ├── cypress
│ │ ├── constants
│ │ │ └── kyc-mock-constants.ts # Imports from @repo/mock/rules
│ └── ...
The import causing the issue
From packages/e2e/cypress/constants/kyc-mock-constants.ts:
// Import using the exports field from package.json
import { RULES, SSNS } from '@repo/mock/rules';
From packages/mock/package.json:
"exports": {
"./rules": {
"types": "./src/handlers/kyc/rules.ts",
"default": "./dist/handlers/kyc/rules.js"
}
}
Steps to reproduce
- Have a pnpm monorepo with workspace packages (using "workspace:*" in package.json)
- Create a Cypress test that imports from a workspace package (e.g.,
import { RULES } from '@repo/mock/rules') - Run the Cypress tests using the GitHub Action
Current workflow
# Install Cypress dependencies. Since we're in a monorepo, tell Cypress to look at the root package.json/lockfile
# Don't run the tests yet, we'll do that later in the proper directory
- name: Install Cypress dependencies
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Build mock package
run: pnpm build --filter @repo/mock
- name: Run Cypress tests
uses: cypress-io/github-action@v6
env:
# Environment variables here
with:
install: false
working-directory: packages/e2e
browser: chrome
record: true
parallel: true
tag: "Staging"
Expected behavior
The Cypress tests should be able to resolve and import the workspace package modules.
Actual behavior
Cypress webpack preprocessor fails to resolve the imports, resulting in the above error.
Additional information
- The issue seems to be related to how the GitHub Action configures Cypress with pnpm workspaces
- The mock package is built successfully before running the tests
- The same tests run fine locally with
pnpm cy:run
Expected behavior
The Cypress tests should be able to resolve and import the workspace package modules.
Actual behavior
Cypress webpack preprocessor fails to resolve the imports, resulting in the above error.
Possible solutions
- Add native support for pnpm workspaces in the github-action
- Provide built-in webpack configuration options for monorepos in the action
- Document a recommended approach for handling pnpm workspaces with Cypress
Any guidance on how to fix this issue would be greatly appreciated!
- Lingua principale
- JavaScript
- Stelle
- 1.5k
- Fork
- 356
- Merge medio
- 1g 9h
- PR unite (30g)
- 28
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cypress-io/github-action
-
Renovate: lock file maintenance fails in Yarn ModernForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug renovate
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cypress-io/github-action#1910 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
renovate
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
cypress-io/github-action#1911 ·
I maintainer di solito rispondono entro 1 giorno
-
Yarn v1 Classic unsupported - deprecation is dueForse di nuovo libera @MikeMcC399 l’ha presa 127 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation
cypress-io/github-action#1819 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Migrate to ESMApertatype: enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
cypress-io/github-action#1647 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Cypress.env deprecation / cy.env additionForse di nuovo libera @MikeMcC399 l’ha presa 63 giorni fa e non c’è nessuna pull request aperta. Apertatests type: enhancement
cypress-io/github-action#1620 · 8 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cypress-io/github-action
Issue simili
-
binding:python bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage potential-regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
aws/aws-sdk-js-v3#8408 ·
I maintainer di solito rispondono entro 1 giorno
-
[v3] KeyBindingManager calls (Add/Remove) are not converted into a case-insensitive accelerator.KeyApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100