Enable support for Cypress tests that rely on workspace packages
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- cypress, github-actions, javascript
Línea de trabajo
Comienza con .github/workflows/web-e2e-deployed-environments.yml y packages/e2e/cypress.config.ts, y luego reproduce el fallo usando el flujo de trabajo de pnpm workspace mostrado. Traza cómo la GitHub Action invoca Cypress y cómo el webpack preprocessor resuelve @repo/mock/rules. Se considera completado cuando los imports de paquetes del workspace se resuelven en la action, o cuando una configuración documentada los habilita de forma fiable.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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!
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.5k
- Forks
- 356
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 28
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cypress-io/github-action
-
Renovate: lock file maintenance fails in Yarn ModernQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug renovate
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
cypress-io/github-action#1910 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
renovate
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
cypress-io/github-action#1911 ·
Los mantenedores suelen responder en 1 día
-
Yarn v1 Classic unsupported - deprecation is dueQuizá libre de nuevo @MikeMcC399 la tomó hace 129 días y no hay ningún pull request abierto. Abiertodocumentation
cypress-io/github-action#1819 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Migrate to ESMAbiertotype: enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
cypress-io/github-action#1647 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Cypress.env deprecation / cy.env additionQuizá libre de nuevo @MikeMcC399 la tomó hace 64 días y no hay ningún pull request abierto. Abiertotests type: enhancement
cypress-io/github-action#1620 · 8 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de cypress-io/github-action
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
routing: the tray panel's stage stands still with motion reduced while a request is in flightAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
microsoft/monaco-editor#5577 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
obsidianmd/obsidian-help#1169 ·
Los mantenedores suelen responder en 2 días
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepPosiblemente ocupada @albertteoh la tomó hoy. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
jaegertracing/jaeger-ui#4739 ·
Los mantenedores suelen responder en 1 día