-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Yarn Modern Plug'n'Play (PnP) TypeScript E2E scaffolds as JavaScript #31084
Comments
Logic is here essentially: https://github.com/cypress-io/cypress/blob/develop/packages/scaffold-config/src/detect.ts#L85 You could turn on DEBUG logs and see which logic we're currently following through here since the debug logs should express this. |
Thanks for linking to the module where the error occurs! cypress/packages/scaffold-config/src/detect.ts Lines 170 to 180 in 760f600
Using the export DEBUG=cypress:scaffold-config:detect
So it seems that I did try to check this with a simple JS one-liner
console.log(require.resolve('typescript')) node test-ts.js fails
yarn node test-ts.js succeeds with:
I'm afraid I'm out of my depth to go into this further. Sorry! The original steps are reproducible, so I leave it to you to decide if the issue should be actioned. |
It may require some help from the Yarn Modern maintainers. |
I found a hint in an old Cypress issue regarding pnp. I couldn't find This detects the installation of typescript in a Yarn PnP or non-PnP environment and works when called directly as: node test-ts.js
try {
const pnp = require('./.pnp.cjs')
pnp.setup()
console.log('Yarn PnP is enabled')
}
catch {
console.log('Yarn PnP not found')
}
try {
const typescriptFile = require.resolve('typescript')
console.log('Resolved typescript from %s', typescriptFile)
} catch {
console.log('No typescript installed')
} This could be the basis for a feature request. I think it goes beyond a simple bug resolution. Note that this only demonstrates that the current https://github.com/cypress-io/cypress/blob/develop/packages/scaffold-config/src/detect.ts is not coded to deal with Yarn PnP. It shows one way of plugging the gap, however the code above cannot be put directly into Cypress. It only works inside a repo which is already configured with Yarn PnP. |
Current behavior
The Cypress scaffolding process sets up a TypeScript E2E project using JavaScript. The project consists of Yarn Modern
4.x
and TypeScript5.x
dependencies, with Yarn configured using the default nodeLinker setting ofpnp
(Plug'n'Play).Scaffolding detection is incompatible with Yarn Modern Plug'n'Play (PnP).
Desired behavior
Cypress should detect TypeScript if installed, whatever Yarn Modern nodeLinker is set to.
Test code to reproduce
Note that all configuration files have a
js
(JavaScript) extension, not ats
(TypeScript) extension.Now change to
nodeLinker
node-modules
and repeat:rm -rf cypress cyoress.config.js yarn config set nodeLinker node-modules yarn install yarn cypress open --e2e --browser electron
Now TypeScript is detected and Cypress configuration files have a
ts
extension.Cypress Version
14.0.3
Node version
v22.14.0
LTSOperating System
Ubuntu
24.04.2
LTSDebug Logs
export DEBUG=cypress:scaffold-config:frameworks
Other
This may be a feature request instead of a bug. In case of it being a feature request, the documentation should be changed to indicate non-support of this configuration.
Related to
The text was updated successfully, but these errors were encountered: