Cypress fails to parse environment variables with commas
See original GitHub issueCurrent behavior:
Cypress fails to run when passing an environment variable containing a comma.
Command run:
cypress open --env ABC="1,2,3"
Stacktrace:
A JavaScript error occurred in the main process Uncaught Exception: TypeError: Cannot read property ‘split’ of undefined at pipesToCommas (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/lib/util/args.js:95:14) at JSONOrCoerce (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/lib/util/args.js:115:9) at /home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:13402:38 at /home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4911:15 at baseForOwn (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:2996:24) at Function.mapValues (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:13401:7) at /home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4374:28 at arrayReduce (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:683:21) at baseWrapperValue (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:4373:14) at LodashWrapper.wrapperValue (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/node_modules/lodash/lodash.js:9052:14) at sanitizeAndConvertNestedArgs (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/lib/util/args.js:151:4) at Object.toObject (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/lib/util/args.js:227:21) at Object.start (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/lib/cypress.js:77:40) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/index.js:27:43) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/packages/server/index.js:29:3) at Module._compile (module.js:642:30) at Object.Module._extensions…js (module.js:653:10) at Module.load (module.js:561:32) at tryModuleLoad (module.js:504:12) at Function.Module._load (module.js:496:3) at Module.require (module.js:586:17) at require (internal/module.js:11:18) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/index.js:2:1) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/app/index.js:3:3) at Module._compile (module.js:642:30) at Object.Module._extensions…js (module.js:653:10) at Module.load (module.js:561:32) at tryModuleLoad (module.js:504:12) at Function.Module._load (module.js:496:3) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/electron.asar/browser/init.js:186:8) at Object.<anonymous> (/home/ehlerts/.cache/Cypress/3.3.1/Cypress/resources/electron.asar/browser/init.js:188:3) at Module._compile (module.js:642:30) at Object.Module._extensions…js (module.js:653:10) at Module.load (module.js:561:32) at tryModuleLoad (module.js:504:12) at Function.Module._load (module.js:496:3) at Function.Module.runMain (module.js:683:10) at startup (bootstrap_node.js:196:16) at bootstrap_node.js:622:3
Once the stacktrace has been printed, nothing happens.
Desired behavior:
Cypress should be able to parse environment variables containing commas.
Steps to reproduce: (app code and test code)
Run the following from a terminal:
cypress open --env ABC="1,2,3"
Versions
Tested Cypress versions: 3.3.1, 3.2.0, 3.1.5 Operating system: Ubuntu 18.04.2 LTS
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top GitHub Comments
I can’t help thinking it would be less confusing to allow multiple
--env
flags and just have onevariable=value
pair per--env
— but if you try that, Cypress ignores all but the last one 😦Confirmed, this is happening in version 3.4.0 of Cypress.
This is the culprit line of code: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/args.js#L95