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.

Record is not reading env variable set in cypress.json or cypress.env.json

See original GitHub issue

Current behavior:

Not able to run the cypress run --record command without a flag, when storing the key as an ENV variable

It works exporting the variable first and then run the cypress run --record

Desired behavior:

Being able to store env variable

How to reproduce:

  1. Set env as following in: cypress.json

{ "projectId": "1280ayu", "env": { "cypress_record_key": "88897382" } } CYPRESS_RECORD_KEY or RECORD_KEY or record_key 2. run: cypress run --record 3. Issue occurs: User gets error:


You can pass us your Record Key like this:

  cypress run --record --key <record_key>

You can also set the key as an environment variable with the name CYPRESS_RECORD_KEY.

https://on.cypress.io/how-do-i-record-runs

Same thing happens if user tries to store it in: cypress.env.json

Test code:


Additional Info (images, stack traces, etc)

  • Operating System: Ubuntu
  • Cypress Version: 1.0.3
  • Browser Version: Chrome 61

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
donaldshencommented, Feb 6, 2020

Okay I see the source of confusion - but I’d rather err on the side of not supporting this. It would be easy to do so - but this is a secret key that should not be written alongside of your other environment variables.

It would be easy enough for you to choose to embed it somewhere in your npm scripts or a script you write using the Cypress Module API, but I wouldn’t recommend it being in cypress.json or cypress.env.json. It’s only useful when choosing to record to the Dashboard, which is typically only run in CI. In those situations using CI based environment variables, or adding it directly to the cypress run command would be advisable.

I would be open to changing this if a more compelling use case could be justifed.

https://docs.cypress.io/guides/guides/environment-variables.html#Option-2-cypress-env-json

I would like to manage record key in cypress.env.json and gitignore the file, rather than export it in local bash_profile, as this doc suggests.

0reactions
jennifer-shehanecommented, Feb 18, 2020

@donaldshen @kfriars Please open a new issue detailing exactly what and why you want this feature request. 2+ yr old issues are not the place to ask for feature requests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Variables | Cypress Documentation
Values in here will overwrite conflicting environment variables in your Cypress configuration. This strategy is useful because if you add cypress.
Read more >
Environment Variables in Cypress - Tools QA
This article covers - What are environment variables in Cypress? How to access them in Cypress?How to set Environment variables in Cypress?
Read more >
Specify environment variables for Cypress tests - BrowserStack
Learn how to specify environment variables for your Cypress tests while running them on BrowserStack.
Read more >
Define variables in cypress.env.json - Stack Overflow
I moved cypress. env. json into another folder, as I checked in settings - Cypress found correctly variables from cypress. json, but the...
Read more >
Specify Environment Variables with Cypress Testing
Cypress Test Environment Variables · Using the env option key in your Cypress configuration file · Create a cypress.env.json file and specify your...
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