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

fix: allow cypress config.port to override devServer.port for proxying assets #27677

Merged
merged 30 commits into from
Aug 29, 2023

Conversation

brian-mann
Copy link
Member

@brian-mann brian-mann commented Aug 28, 2023

Additional details

Steps to test

How has the user experience changed?

PR Tasks

@@ -122,6 +125,7 @@ function makeCypressViteConfig (config: ViteDevServerConfig, vite: Vite): Inline
vite.searchForWorkspaceRoot?.(process.cwd()),
],
},
port: vitePort,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just be port - if port is provided, it's a number, otherwise it'll be undefined. No need for the vitePort variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it’s needed because of types. Cypress provided types are number or null. Vite is number or undefined. Switch it and it’ll yell at you.

@@ -106,6 +109,7 @@ export function makeCypressWebpackConfig (
return {
...finalConfig,
devServer: {
port: webpackDevServerPort,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again just port is okay, but this is more explicit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types problem without coercing to undefined

@@ -240,6 +240,11 @@ export class ProjectLifecycleManager {

const devServerOptions = await this.ctx._apis.projectApi.getDevServer().start({ specs: this.ctx.project.specs, config: finalConfig })

// if we received a cypressConfig.port we want to null it out
// because we propagated it into the devServer.port and it is
// later set as baseUrl which cypress is launched into
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth adding a link to the issue that explain this

@@ -114,7 +115,7 @@ export const normalizeStdout = function (str: string, options: any = {}) {

// remove all of the dynamic parts of stdout
// to normalize against what we expected
str = str
str = stripAnsi(str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we need to change this to stripAnsi here

@mschile
Copy link
Contributor

mschile commented Aug 28, 2023

Would a user ever have another service running that is expecting the devServer to be at the port defined in the devServer config? Would if make more sense to throw an error if there are conflicting values?

Co-authored-by: Bill Glesias <bglesias@gmail.com>
@cypress
Copy link

cypress bot commented Aug 28, 2023

1 flaky test on run #50611 ↗︎

0 479 6 0 Flakiness 1

Details:

fix tests
Project: cypress Commit: e684546d71
Status: Passed Duration: 12:28 💡
Started: Aug 29, 2023 4:40 AM Ended: Aug 29, 2023 4:52 AM
Flakiness  cypress/e2e/specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test Artifacts
App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs Test Replay Output Screenshots

Review all test suite changes for PR #27677 ↗︎

@lmiller1990
Copy link
Contributor

Would a user ever have another service running that is expecting the devServer to be at the port defined in the devServer config? Would if make more sense to throw an error if there are conflicting values?

Just to clarify are you suggesting we check if the port is available that the user asked for, and if it's not, we error instead of auto increment (this is what vite/webpack seem to do).

Comment on lines +13 to +14
export default defineConfig({
videoCompression: false, // turn off video compression for CI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not needed since it's off by default.

Suggested change
export default defineConfig({
videoCompression: false, // turn off video compression for CI
export default defineConfig({

@ryanthemanuel ryanthemanuel merged commit e5c7116 into develop Aug 29, 2023
78 of 80 checks passed
@ryanthemanuel ryanthemanuel deleted the fix/config-port-overriding-devserver branch August 29, 2023 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting port on cypress config does not propagate to component devServers
5 participants