-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cypress PowerShell: broken comma-separated-values CLI parsing since NodeJS 22.0.0 #6166
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
Comments
--env
parsing since NodeJS 22.0.0--env
parsing since NodeJS 22.0.0
--env
parsing since NodeJS 22.0.0
|
Not a duplicate because that specific issue no longer is reproducible on the newest Cypress version with NodeJS 16.18.1 I'm surprised nobody reported on this issue |
I changed it to "similar to ..." since the resolution was to enclose the option in quotes when using Windows PowerShell and this led to the addition of this instruction to the documentation. The resolution of your issue would be to add quotes to your command in PowerShell: npx cypress run --env "a=1,b=2,c=3" You can see this also if you use Windows 11 24H2 npx cypress open --e2e --browser electron --env "a=1,b=2,c=3" |
Perhaps we should update out docs to always recommend comments around the values? |
Good point. The instructions are a little hidden on https://docs.cypress.io/app/references/environment-variables#Option-4---env and there is nothing on the https://docs.cypress.io/app/references/command-line about special requirements of PowerShell. I believe it is due to the comma character causing PowerShell to split out the parameters. Quoting the parameter stops PowerShell from attempting any further parsing. This issue should probably go into https://github.com/cypress-io/cypress-documentation or a new one could be opened there. |
Ok I made a npm PR based on patch here npm/cli#8267 hopefully this could get backported to NodeJS 22 and NodeJS 24 at some point |
Moved issue to docs |
Thanks for finding the cli issue and following up with npm! I suggest to wait for the resolution of the npm PR npm/cli#8267 before adding anything to the Cypress documentation, which already contains a hint in https://docs.cypress.io/app/references/environment-variables#Option-4---env
"scripts": {
"cy:env": "cypress run --env a=1,b=2"
}, npm run cy:env
|
This issue also affects Yarn and pnpm running in Windows with PowerShell, so probably the npm PR will not fix all situations.
For Yarn and pnpm the issue is also present with Node.js 20. These PowerShell inconsistencies are not really something that Cypress can sort out. The pragmatic solution is to use quotes if necessary. |
PowerShell Command
Current behavior
NodeJS 22.0.0 is different from older versions that it includes
C:\Program Files\nodejs\npx.ps1
fileDesired behavior
Test code to reproduce
cypress/e2e/spec.cy.js
cypress.config.js
Cypress Version
any (14.3.2 tested)
Node version
v22.0.0+ (v22.15.0 tested)
Operating System
Windows 10 22H2
Extra Information
--env
and--config
parsingC:\Program Files\nodejs\npx.ps1
is a workaroundThe text was updated successfully, but these errors were encountered: