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

Add --config-file CLI argument #1369

Closed
kentcdodds opened this issue Feb 23, 2018 · 23 comments · Fixed by #3246
Closed

Add --config-file CLI argument #1369

kentcdodds opened this issue Feb 23, 2018 · 23 comments · Fixed by #3246
Assignees
Labels
cli type: feature New feature that does not currently exist

Comments

@kentcdodds
Copy link

kentcdodds commented Feb 23, 2018

Current behavior:

I cannot specify a configuration file path

Desired behavior:

I want to specify a configuration file path

Test code:

cypress run --config-file "/path/to/config"

Additional Info (images, stack traces, etc)

I'm building a tool for PayPal called paypal-scripts (similar to react-scripts). One of the purposes is to cover 80% of the use cases by hiding all configuration from the user of the tool so they can focus on just writing the code. If they do create a cypress.json file then we'll use that one, but for most people they should be able to just use the built-in configuration of paypal-scripts and they wont need to have and maintain a cypress.json file at all. There's honestly not a lot of configuration we'd need (mostly the baseUrl I think), but a lot of the value proposition of paypal-scripts is that people don't need to worry about configuring anything and it all just works out of the box.

I'm able to do this with eslint, babel, and many other tools, but I can't currently do it with cypress and I'd like to be able to do that if possible :) Thoughts?

@jennifer-shehane
Copy link
Member

Would probably call the arg --configFile in keeping with the naming convention of our other file path args: https://on.cypress.io/configuration#Folders-Files

@jennifer-shehane jennifer-shehane added cli type: feature New feature that does not currently exist stage: ready for work The issue is reproducible and in scope labels Feb 23, 2018
@kentcdodds
Copy link
Author

That sounds great 👍

@brian-mann
Copy link
Member

Yeah this has come up before in a longer thread here - #909 (comment)

I agree with the need for this. At the moment cypress is hard coded to look for the cypress.json file.

But, today -- for dynamic configuration - you could use plugins/index.js to modify all of the values before they're handed off to Cypress - https://docs.cypress.io/api/plugins/configuration-api.html

We have some examples that might satisfy your requirements today.

@kentcdodds
Copy link
Author

The problem is that I'm trying to hide away all the configuration and if I have to tell people they have to do something fancy in plugins/index.js to make things work then that goal isn't really accomplished. So that wont work right now. I need the config to live within my package: node_modules/paypal-scripts/dist/config/cypress.json.

This isn't a huge rush for me, but I don't know that I'll be able to do any work on paypal-scripts in this regard until this has been done.

@reintroducing
Copy link

i am facing the exact same issue at SpotHero at the moment and would love to also have this option available.

@TroutZen
Copy link

Also have a use for this. I have a repo with tests for multiple services that each needs its own config file.

@haleagar

This comment has been minimized.

@brian-mann
Copy link
Member

You can use the plugins API to programmatically alter the configuration in whatever way you want today.

You can simply have an empty cypress.json file and then merge in whatever you'd like based on whatever you'd like in whatever manner you want.

https://docs.cypress.io/api/plugins/configuration-api.html

I am confident this can handle whatever you want to throw at it.

@kentcdodds
Copy link
Author

Probably so, but that would require that people have the plugin installed. For my use case I want people to be able to simply run: paypal-scripts e2e and it'll start things up for them without them having to have any configuration of plugins setup. The less in their filesystem the less they can mess up/have to maintain.

@vinnymac
Copy link

The docs here kind of allow for this, although I had to fix it to get it working properly in a freshly setup project on version 3.1.0.

const pathToConfigFile = path.resolve('..', 'config', `${file}.json`)

became

const pathToConfigFile = path.resolve('cypress', 'config', `${file}.json`)

It is strange to me that something like this would not be built in. It is a necessity to be able to differentiate between environments and fixtures.

@jennifer-shehane jennifer-shehane changed the title Add --config CLI argument Add --configFile CLI argument Jan 24, 2019
@jennifer-shehane jennifer-shehane added stage: current and removed stage: ready for work The issue is reproducible and in scope labels Jan 24, 2019
@jennifer-shehane
Copy link
Member

Also consider allowing user to pass configFile: false as part of this issue, this is a request we've seen from some users - #2711

@flotwig
Copy link
Contributor

flotwig commented Jan 30, 2019

Working on this right now. Should we replace all the references to "cypress.json" in the desktop-gui with something else, to indicate that the user is using a custom config?

@Toxicable
Copy link
Contributor

Would be great to see this feature in master.
It would help a lot with the Bazel intergration im working on here: bazelbuild/rules_nodejs#607

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Apr 26, 2019
@rodoabad
Copy link

Eagerly waiting! 👍

@SurajChande
Copy link
Contributor

Eagerly waiting! 👍

Same here!

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels May 22, 2019
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels Jul 2, 2019
@flotwig flotwig changed the title Add --configFile CLI argument Add --config-file CLI argument Jul 3, 2019
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Jul 9, 2019
@talentlessguy
Copy link

Very much needed!

@talentlessguy
Copy link

talentlessguy commented Sep 29, 2019

This is cool that option is merged but it doesn't seem to be working :/

> yarn test:update
yarn run v1.17.3
$ cypress run --record --config-file update.cypress.json

  error: unknown option: --config-file

Cypress version: 3.4.1

@brian-mann
Copy link
Member

@talentlessguy our cypress-bot comments on all closed issues indicating that they have yet to be released. This fix is slated for 3.5.0, which is why it's not in 3.4.1. Apparently the cypress-bot stopped working a couple days ago and we're fixing it.

@brian-mann
Copy link
Member

@talentlessguy actually the cypress-bot is working, I'm not sure why it didn't comment on this issue, but here's an example of what it typically does: #4822 (comment)

@talentlessguy
Copy link

@brian-mann okay, good luck with fixing cypress-bot. I hope 3.5.0 will be released soon.

@leonfs
Copy link

leonfs commented Oct 18, 2019

Same here - this would be a great option. We tried to modify the blacklistsHosts list in the plugins file, but for some an unknown reason, the config always ended with the same blacklistsHosts that in the .json file. It must be a bug. All other properties modified by the plugin were actually showing the expected values.

@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 18, 2019
@jennifer-shehane
Copy link
Member

The code for this is done in #3246, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.