bug: Stencil can resolve incorrect jest-runner dependency when using pnpm

Abierto
#5,196 1 comentario 2 reacciones 0 asignados Ver en GitHub

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
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
typescript

Línea de trabajo

Reproduce el fallo de packages/stencil con pnpm install seguido de pnpm test.spec; después, rastrea la resolución del runner desde @stencil/core/testing/index.js usando el stack trace proporcionado. Se considera terminado cuando se selecciona el runner de Jest v29 para el proyecto Stencil a pesar de que otro paquete del workspace usa Jest v26 y las pruebas se completan correctamente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug: Validated
Prerequisites
Stencil Version

v4.9.0

Current Behavior

In a mono-repo using pnpm where you have mixed dependency versions of Jest, specifically the jest-runner package, Stencil will incorrectly use an older version of the jest-runner package, even though the Stencil project may be configured with a newer version.

For example, in a project that has Jest v29 for the Stencil project, but another package with Jest v26, Stencil will use the test facade for Jest v29, but use the jest-runner@26 instance when executing the test runner.

This results in an exception:

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

I've modified the bundle to provide the entire stack trace:

TypeError: Cannot read properties of undefined (reading 'serial')
    at e.runTests (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/[email protected]/node_modules/jest-runner/build/index.js:108:27)
    at e.runTests (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/testing/index.js:926:19)
    at TestScheduler.scheduleTests (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@jest/core/build/TestScheduler.js:283:32)
    at async runJest (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@jest/core/build/runJest.js:367:19)
    at async _run10000 (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@jest/core/build/cli/index.js:343:7)
    at async runCLI (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@jest/core/build/cli/index.js:198:3)
    at async runJest (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/testing/index.js:900:10)
    at async Object.run (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/testing/index.js:12865:10)
    at async taskTest (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/cli/index.cjs:2395:24)
    at async runTask (/Users/sean/Documents/ionic/issues/ionic-framework/node_modules/.pnpm/@[email protected]/node_modules/@stencil/core/cli/index.cjs:2514:13)

This behavior is likely driven from pnpm hoisting the dependency, changing the execution location from which Stencil uses to grab the jest-runner instance and invoke it. I suspect we will need to make stricter assumption around where this instance lives, such as from the rootDir of the project, instead of from the executing node_modules.

Expected Behavior

Stencil should resolve its own dependency of the jest-runner, regardless of if the workspace is using another dependency for another project in the mono-repo.

System Info
`npx stencil info` fails with:
> npm ERR! could not determine executable to run
Steps to Reproduce
  1. Clone the repository - it is a mono-repo.
  2. Install pnpm, if not already installed: https://pnpm.io/installation
  3. Install project dependencies: pnpm install
  4. Run unit tests for the Stencil project: cd packages/stencil && pnpm test.spec
  5. Observe: Exception is thrown, tests do not run successfully.
  6. Expected: Tests run successfully.
Code Reproduction URL

https://github.com/sean-perkins/stencil-pnpm-issue

Additional Information

Workarounds:

  1. Downgrade to the lowest version of Jest that is compatible with Stencil, for example with the reproduction downgrading the Stencil project to Jest v26.
  2. Upgrade all packages in the mono-repo to the same version of Jest as the Stencil project.
  3. Use npm or a package manager that does not hoist dependencies.
Lenguaje dominante
TypeScript
Estrellas
13.2k
Forks
865
Merge medio
2 d 16 h
PR fusionados (30 d)
29

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de stenciljs/core

Todos los issues de stenciljs/core

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.