Skip to content

fix(tools): handle mixed-separator cwd on Windows in snap test output replacement#707

Merged
fengmk2 merged 2 commits intomainfrom
fix-windows-e2e
Mar 6, 2026
Merged

fix(tools): handle mixed-separator cwd on Windows in snap test output replacement#707
fengmk2 merged 2 commits intomainfrom
fix-windows-e2e

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Mar 6, 2026

On Windows, cwd built with template literals has mixed separators
(e.g., C:\Users\...\Temp/test-name) while Vite's error messages use
all-backslash paths from path.resolve(). The cwd replacement in
replaceUnstableOutput() failed to match, leaking full temp paths into
snap test output.

Fix by also trying the all-backslash form of cwd (and its parent) for
replacement, with trailing-separator handling to normalize the path
separator after the <cwd> placeholder.

… replacement

On Windows, cwd built with template literals has mixed separators
(e.g., `C:\Users\...\Temp/test-name`) while Vite's error messages use
all-backslash paths from path.resolve(). The cwd replacement in
replaceUnstableOutput() failed to match, leaking full temp paths into
snap test output.

Fix by also trying the all-backslash form of cwd (and its parent) for
replacement, with trailing-separator handling to normalize the path
separator after the `<cwd>` placeholder.
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 6, 2026

Deploy Preview for viteplus-staging canceled.

Name Link
🔨 Latest commit 267e186
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-staging/deploys/69aa4fadaa6e18000850d88b

@fengmk2 fengmk2 self-assigned this Mar 6, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 6, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Remove process.platform mocking in favor of describe.skipIf on
non-Windows. This lets the tests exercise real Windows path.dirname
behavior without workarounds for POSIX path semantics.
@fengmk2 fengmk2 marked this pull request as ready for review March 6, 2026 03:53
@fengmk2 fengmk2 merged commit 7016e34 into main Mar 6, 2026
22 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Mar 6, 2026

Merge activity

@fengmk2 fengmk2 deleted the fix-windows-e2e branch March 6, 2026 04:07
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.

2 participants