-
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
fix: vite-dev-server windows #25889
fix: vite-dev-server windows #25889
Conversation
6 flaky tests on run #44300 ↗︎
Details:
cypress\e2e\scaffold-component-testing.cy.ts • 1 flaky test • launchpad-e2e
cypress\e2e\create-from-component.cy.ts • 1 flaky test • app-e2e
cypress\e2e\specs.cy.ts • 2 flaky tests • app-e2e
cypress\e2e\specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e
cypress\e2e\cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
let testFileAbsolutePathRoute | ||
|
||
if (CypressInstance.config('platform') === 'win32') { | ||
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${CypressInstance.spec.absolute}` | ||
} else { | ||
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs${CypressInstance.spec.absolute}` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to suggest a adding a comment here. The difference between the 2 lines is one character in the middle of a string, which is hard to notice at glance.
But we could also change the code so that the difference is more obvious? Something like:
let testFileAbsolutePathRoute | |
if (CypressInstance.config('platform') === 'win32') { | |
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${CypressInstance.spec.absolute}` | |
} else { | |
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs${CypressInstance.spec.absolute}` | |
} | |
let testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs` | |
if (CypressInstance.config('platform') === 'win32') { | |
testFileAbsolutePathRoute += `/${CypressInstance.spec.absolute}` | |
} else { | |
testFileAbsolutePathRoute += `${CypressInstance.spec.absolute}` | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be clearer to remove the OS check and just normalize the absolute path to ensure it doesn't have a leading slash before we work with it
// Normalize path to not include a leading slash (different on Win32 vs Unix)
const normalizedAbsolutePath = CypressInstance.spec.absolute.replace(/^\//, '')
const testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${normalizedAbsolutePath}`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess - my concern here is actually the fact we need a comment and a regular expression seems much more complex, or the string concatenation, both seem more complex than just a good old if/else
statement, where you can immediately glance and see the difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should add a comment here explaining why this is required, let me update that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I thought more - let's go with normalzing, it does look better, after all - thanks!
Windows passing, going to merge. |
Fixing a regression introduced by #25801 (in develop, but not yet in the wild) which broke
vite-dev-server
on Windows.Testing: Observe windows CI, it's passing - as opposed to develop, where many Vite Dev Server tests are failing.