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: vite-dev-server windows #25889

Merged
merged 13 commits into from
Feb 22, 2023
Merged

fix: vite-dev-server windows #25889

merged 13 commits into from
Feb 22, 2023

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Feb 21, 2023

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.

@cypress
Copy link

cypress bot commented Feb 21, 2023

6 flaky tests on run #44300 ↗︎

0 662 32 0 Flakiness 6

Details:

Merge branch 'develop' into lmiller/fixing-vite-windows
Project: cypress Commit: e27734bcc2
Status: Passed Duration: 18:20 💡
Started: Feb 22, 2023 1:21 AM Ended: Feb 22, 2023 1:40 AM
Flakiness  cypress\e2e\scaffold-component-testing.cy.ts • 1 flaky test • launchpad-e2e

View Output Video

Test
scaffolding component testing > vuecli4vue2 > scaffolds component testing for Vue CLI 4 w/ Vue 2 project Screenshot
Flakiness  cypress\e2e\create-from-component.cy.ts • 1 flaky test • app-e2e

View Output Video

Test
... > Shows create from component card for React projects Screenshot
Flakiness  cypress\e2e\specs.cy.ts • 2 flaky tests • app-e2e

View Output Video

Test
... > create template spec > shows dialog that can be dismissed with Close (x) button press Screenshot
... > opens config file in ide from SpecPattern Screenshot
Flakiness  cypress\e2e\specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e

View Output Video

Test
App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs Screenshot
Flakiness  cypress\e2e\cypress-origin-communicator.cy.ts • 1 flaky test • app-e2e

View Output Video

Test
Cypress In Cypress Origin Communicator > cy.origin passivity with app interactions > passes upon test reload mid test execution Screenshot

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

Comment on lines 37 to 43
let testFileAbsolutePathRoute

if (CypressInstance.config('platform') === 'win32') {
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${CypressInstance.spec.absolute}`
} else {
testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs${CypressInstance.spec.absolute}`
}
Copy link
Contributor

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:

Suggested change
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}`
}

Copy link
Contributor

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}`

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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!

@lmiller1990
Copy link
Contributor Author

Windows passing, going to merge.

@lmiller1990 lmiller1990 merged commit 0981fcf into develop Feb 22, 2023
@lmiller1990 lmiller1990 deleted the lmiller/fixing-vite-windows branch February 22, 2023 02:44
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.

4 participants