Skip to content
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

[feature request] Allow setting --record switch with env var #4876

Open
pieh opened this issue Jul 30, 2019 · 6 comments
Open

[feature request] Allow setting --record switch with env var #4876

pieh opened this issue Jul 30, 2019 · 6 comments
Labels
stage: ready for work The issue is reproducible and in scope type: enhancement Requested enhancement of existing feature

Comments

@pieh
Copy link

pieh commented Jul 30, 2019

Current behavior:

Right now you can specify Project ID and key with env vars (CYPRESS_PROJECT_ID, CYPRESS_RECORD_KEY). But you do need to use CLI --record switch to actually make use of them. If you use --record flag without those env vars you get error:

You passed the --record flag but this project has not been setup to record.

This project is missing the 'projectId' inside of 'cypress.json'.

We cannot uniquely identify this project without this id.

You need to setup this project to record. This will generate a unique 'projectId'.

Alternatively if you omit the --record flag this project will run without recording.

https://on.cypress.io/recording-project-runs

This makes it challenging (or messy) to use scripts that would work when those env vars are set and when they are not. In our setup we want to record runs to dashboard only when run in CI and not when running them locally (to not pollute dashboard with any test runs that devs will run locally when testing their changes.

As solution/workaround we use scripts like "cy:run": "(is-ci && cypress run --browser chrome --record) || cypress run --browser chrome" to apply --record switch only in CI. ( gatsbyjs/gatsby#16190 )

Desired behavior:

I'd like to be able to use env var like CYPRESS_RECORD=true to control all recording related options with env vars.

Steps to reproduce: (app code and test code)

  • create single script to run cypress test suites (with --record switch)
  • specify CYPRESS_PROJECT_ID, CYPRESS_RECORD_KEY in your CI setup
  • try running script locally without above env vars set

Versions

cypress: 3.3.2

@pieh
Copy link
Author

pieh commented Jul 30, 2019

I'm happy to dive in, implement it and open pull request if this would be accepted

@jennifer-shehane jennifer-shehane added the type: enhancement Requested enhancement of existing feature label Jul 30, 2019
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Jul 31, 2019

Yes, this sounds like a great use case. We would happily accept a PR.

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jul 31, 2019
@brian-mann
Copy link
Member

Sure, this feature sounds fine. We would accept a PR for this or one of our devs could likely knock it quickly.

At the moment I suggest you writing your own scripts/run-cypress.js file that you use to determine whether to record in cypress or not. At least then you could more easily programmatically build up an options object to pass to cypress.run(...)

@kthy
Copy link

kthy commented Jul 23, 2020

If anybody ever gets around to this, it seems to me it would make sense to tackle #938 at the same time: Make it possible to set CYPRESS_RECORD_KEY in cypress.env.json.

@rupesh1395kumar
Copy link

Any solution for this one
You passed the --record flag but this project has not been setup to record.

This project is missing the projectId inside of: cypress.config.ts

We cannot uniquely identify this project without this id.

You need to setup this project to record. This will generate a unique projectId.

Alternatively if you omit the --record flag this project will run without recording.

@MikeMcC399
Copy link
Contributor

@rupesh1395kumar

You should be able to follow the documentation on

https://docs.cypress.io/guides/cloud/getting-started#Setup

in order to set up Cypress to record to the Cypress Cloud.

Discord chat
(click on button) links to the Cypress technical community on Discord and there is a separate channel for cypress-cloud if you would like to get help from the Cypress community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: ready for work The issue is reproducible and in scope type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

6 participants