-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: support cypress.js for config #15280
Conversation
…config.js for e2e runner
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Internal Jira issue: TR-691 |
@lmiller1990 This will close this issue if you can tag it #5218 |
I don't think we need |
@lmiller1990 Josh is going to set up a meeting soon to discuss the implementation of this with some of the TR team so we can more quickly review. |
@jennifer-shehane thanks, I added a resolves #5218. I will sync w/ Josh to get this meeting organized. |
Slightly changed how/when this will be implemented. First stage is to upgrade Follow up PR: #15444 |
User facing changelog
You may now write your configuration in a JS file. The specifics were discussed in this ticket and summarized in this ticket.
This resolves #5218.
The motivation here is two-fold:
This PR adds support for declaring config via a
cypress.js
file, but also supports different defaults depending on the runner you are using.This new configuration is purely additive -
cypress.json
is the default and will be prioritized if it is found.Read on for more.
Before (
cypress.json
)After: (
cypress.js
by default, but only used ifcypress.json
is not found)If both
cypress.js
andcypress.json
are found, we default tocypress.json
.This means if existing users would like to use the new
cypress.js
configuration, all they need to do ismv cypress.json cypress.js
and wrap their config inmodule.exports = { /* config */ }
.In addition, you may also configure separate files for runner specific configuration. The default file names are:
cypress.component.config.js
for CT runnercypress.e2e.config.js
for the e2e runnerCypress will figure out which one to use based on how you launch Cypress. If you launch with
open-ct
,run-ct
or using the--experimentalComponentTesting
flag, we will usecypress.component.config.js
if is exists. Otherwise, usecypress.e2e.config.js
.Finally, we also support declaring configuration in single
cypress.js
file. In this case, you can configure it with two keys:e2e
andcomponent
.This is neat, since you can easily share some base defaults:
... or ...
etc.
Additional details
This change is necessary since e2e and component testing have different requirements. An example might be in e2e tests, having a default viewport of 660x1000 might make sense, but for a component testing, it's likely something smaller such as 500x500 might be a more useful default.
Furthermore, using JS for configuration is far more powerful and flexible than JSON. In the long run, we could also support TS natively, and then users could get strongly typed configuration for a better DX!
How has the user experience changed?
No change required -
cypress.json
is prioritized by default. You can opt-in to the newcypress.js
or runner specific configuration files.PR Tasks
cypress-documentation
? Not yet. I will do this before marking "ready for review". I am tracking that here.type definitions
Not required.cypress.schema.json
] Need to do this