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

Normalize DevServer Config Resolution #24133

Closed
ZachJW34 opened this issue Oct 5, 2022 · 5 comments · Fixed by #24369
Closed

Normalize DevServer Config Resolution #24133

ZachJW34 opened this issue Oct 5, 2022 · 5 comments · Fixed by #24369
Assignees
Labels
CT Issue related to component testing

Comments

@ZachJW34
Copy link
Contributor

ZachJW34 commented Oct 5, 2022

Current behavior

The config resolution for @cypress/webpack-dev-server and @cypress/vite-dev-server differ.

@cypress/vite-dev-server will always source a <project-root>/vite.config.js and merge the properties with the devServer.viteConfig value if supplied.

@cypress/webpack-dev-server will only source a <project-root>/webpack.config.js if and only if devServer.webpackConfig is undefined.

Desired behavior

The config resolution should be equivalent across dev-servers. I'd argue the @cypress/webpack-dev-server is the proper config resolution, as it allows the user to opt out of Cypress trying to merge in their project root config (which might be a config they don't want to use for CT testing).

Test code to reproduce

Run DEBUG=cypress:vite-dev-server:resolve-config npx cypress open on a Vite based project that has a <project-root>/vite.config.js. Look in the terminal after clicking on CT testing in the launchpad and the resolved config will be logged. Close Cypress and edit the cypress.config.js -> component.devServer.viteConfig property (add a plugin, change port). The changes made will be merged with the properties defined in <project-root>/vite.config.js.

Run DEBUG=cypress:webpack-dev-server:makeWebpackConfig npx cypress open on a Webpack based project that has a <project-root>/webpack.config.js. Follow similar steps described above. Notice that after adding a cypress.config.js -> component.devServer.webpackConfig, the contents of <project-root>/webpack.config.js are no longer merged.

Screen.Recording.2022-10-05.at.12.02.16.PM.mov

NOTE: This would be a breaking change

@baus
Copy link

baus commented Oct 11, 2022

@marktnoonan
Copy link
Contributor

Just noting from the sync with Brian last Wednesday, we have agreed that

the @cypress/webpack-dev-server is the proper config resolution

and that that is the plan for this ticket. It should come with warnings for Vite users.

My suggestion for the vite warnings is to use our existing alert pattern in the app at the top of the specs list, so there’s one place to surface the error, and it’s definitely in the path of the user opening a spec. We would persist their dismissal of the alert in saved state.

When tests are run from the terminal, we would also print a warning to Vite users that config resolution has changed. The text for both warnings would be something like:

The process Cypress uses for Vite config resolution has changed. This may cause unexpected behavior related to your project's Vite config. See our latest docs[link] for more information.

@ZachJW34
Copy link
Contributor Author

@marktnoonan for run mode, is the warning always displayed or displayed only once? When do we stop showing the warning?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 26, 2022

The code for this is done in cypress-io/cypress#24369, but 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 Nov 10, 2022

Released in 11.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v11.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants