Cypress fails to parse command line environment variables when environment variables with empty values are supplied.
Should default to setting the values to undefined
Run a command like cypress run --env="USERNAME=,PASSWORD="
3.2.0 and earlier
Stack trace:
A JavaScript error occurred in the main process
Uncaught Exception:
TypeError: Cannot read property 'split' of undefined
at pipesToCommas (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/util/args.js:95:13)
at JSONOrCoerce (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/util/args.js:115:9)
at /root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:13402:38
at /root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:13401:7)
at /root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4374:28
at arrayReduce (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:683:21)
at baseWrapperValue (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4373:14)
at LodashWrapper.wrapperValue (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:9052:14)
at sanitizeAndConvertNestedArgs (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/util/args.js:150:4)
at Object.toObject (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/util/args.js:225:21)
at Object.start (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/cypress.js:70:40)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/index.js:21:43)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/index.js:23:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/app/index.js:2:1)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/app/index.js:3:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/electron.asar/browser/init.js:171:8)
at Object.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/electron.asar/browser/init.js:173:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:167:16)
at bootstrap_node.js:589:3
The code for this is done in cypress-io/cypress#3743, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 3.3.0.
Just an update in case anyone is still seeing this issue. I had a similar issue happen even after upgrading to 3.3.2 version of Cypress. The issue I had looks something like this,
node_modules/cypress/bin/cypress run --browser chrome --env var1=value1,var2 =value2
The space before = in var2 was causing the same issue. This is not an issue in cypress per se but seems to have been a decision by minimist node module. Just an FYI if someone saw this and was wondering why they are still seeing it even after upgrading cypress.
In case it's useful for someone else, I was doing something pretty silly...
The cypress folder is not at the root of the project so I wanted to launch it with an argument specifying that.
Reading the doc, I found an argument config and I didn't bother reading further :man_facepalming:
So I was doing:
yarn run cypress open --config ./public-site-e2e/cypress.json
This flag's actually not for that at all.
And I have to do instead:
yarn run cypress open --project ./public-site-e2e
The error I had with the first one was
TypeError: Cannot read property 'split' of undefined
So it took me about 20mn to figure out what was wrong :sweat_smile:
@maxime1992 Understandable. We do have an issue to add a --configFile argument. https://github.com/cypress-io/cypress/issues/1369
@maxime1992 @jennifer-shehane
--config sets configuration files on the cli line
The correct way to load a different config:
yarn run cypress open --config-file ./yourconfig.json
Most helpful comment
In case it's useful for someone else, I was doing something pretty silly...
The cypress folder is not at the root of the project so I wanted to launch it with an argument specifying that.
Reading the doc, I found an argument
configand I didn't bother reading further :man_facepalming:So I was doing:
This flag's actually not for that at all.
And I have to do instead:
The error I had with the first one was
TypeError: Cannot read property 'split' of undefinedSo it took me about 20mn to figure out what was wrong :sweat_smile: