question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress fails to parse environment variables with commas

See original GitHub issue

Current 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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
unikitty37commented, Jan 9, 2021

I can’t help thinking it would be less confusing to allow multiple --env flags and just have one variable=value pair per --env — but if you try that, Cypress ignores all but the last one 😦

2reactions
jennifer-shehanecommented, Jul 13, 2019

Confirmed, this is happening in version 3.4.0 of Cypress.

Screen Shot 2019-07-13 at 9 56 25 AM

This is the culprit line of code: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/args.js#L95

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I pass an env name to Cypress tests to load a set ...
So, I created a file called cypress.playground.json but I don't know how to tell Cypress to load it up. { "baseUrl": "https://my ...
Read more >
Environment Variables in Cypress End-to-End Testing
Note: in the Cypress CLI tool, environment variables are delimited by commas. Cypress is able to parse the command and get defined values,...
Read more >
Troubleshooting
Another way to log what is found by Cypress is to run Cypress with the DEBUG environment variable set to cypress:launcher . This...
Read more >
Cypress-tags
This plugin uses TypeScript to parse the tests, so you will need typescript ... passing a comma separated list of tags to the...
Read more >
Use AWS Secrets Manager secrets in GitHub jobs
In this case, the action will fail, because environment variable names must ... you can parse the JSON to set individual environment variables...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found