Skip to content

Builder Vite: Print the found Vite config path with forward slashes on Windows - #36917

Merged
kasperpeulen merged 1 commit into
nextfrom
kasper/vite-config-windows-test
Oct 21, 2026
Merged

kasperpeulen merged 1 commit into
nextfrom
kasper/vite-config-windows-test

Conversation

@kasperpeulen

Copy link
Copy Markdown
Member

Since #36788 landed on next, the daily Windows unit job fails one test in vite-config.test.ts: "discovery miss reporting › warns when configDir is nested and the Vite config sits at the project root".

AssertionError: expected 'No user Vite config was loaded: Story…' to contain '/project/vite.config.mjs'

The test mocks find.any with resolve('/project/vite.config.mjs'), which on Windows is a drive-letter path with backslashes, and then expects the posix string in the warning.

Looking at how the warning is built showed this is not only a test problem. The path that empathic's find.any returns comes from node:path join, so on Windows it has backslashes, and the warning dropped it verbatim into a snippet meant to be pasted into main.ts:

viteConfigPath: 'C:\project\vite.config.mjs'

Inside a JS string literal \v is a vertical tab and \p is just p, so the pasted value is not the path the warning points at.

The fix normalises the found path with pathe before printing it, so the warning reads C:/project/vite.config.mjs on Windows. Vite resolves viteConfigPath with path.resolve, which accepts forward slashes on Windows, so the snippet now works when pasted. The project root and config dir in the prose part of the message are left as they were.

In the test, the nested-configDir case now computes the expected string the same way the code does (pathe normalize of the resolved mock value) and checks it in both the "found at" sentence and the snippet. A new test feeds a literal Windows path (C:\project\vite.config.mjs) into find.any and expects forward slashes in both places, so the Windows behaviour is covered on every platform. I checked the other tests in the describe block: they either never reach the warning or only assert that nothing was logged, and the relative(...) guard gives the same answer on Windows for their inputs, so they need no change.

Files changed:

  • code/builders/builder-vite/src/vite-config.ts
  • code/builders/builder-vite/src/vite-config.test.ts

Manual testing

From the repo root, run yarn test code/builders/builder-vite: 15 files and 95 tests pass on macOS. With the production change reverted, the new Windows-path test fails with expected '…' to contain 'found at "C:/project/vite.config.mjs"', so it guards the fix. yarn lint:js:cmd builders/builder-vite --quiet and yarn nx check builder-vite are clean.

I could not run Windows locally. The argument from the code: on Windows the mocked value is something like D:\project\vite.config.mjs, pathe turns it into D:/project/vite.config.mjs, and the test expects exactly that string, built with the same resolve plus normalize. The ci:daily label is on so the Windows unit job runs on this PR and confirms it.

🤖 Generated with Claude Code

The discovery-miss warning embedded the path from empathic's
find.any verbatim. On Windows that is a backslash path, so the
suggested snippet `viteConfigPath: 'C:\project\vite.config.mjs'`
is not a valid path once pasted into a JS string (`\v` is a
vertical tab), and the nested-configDir test failed on the daily
Windows unit job because it expected the posix form.

Normalise the path with pathe before printing it, compute the
expected string the same way in the test, and add a test that
feeds a Windows path and expects forward slashes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kasperpeulen kasperpeulen added build Internal-facing build tooling & test updates ci:daily Run the CI jobs that normally run in the daily job. qa:skip Pull Requests that do not need any QA. (e.g. documentation) labels Oct 20, 2026
@kasperpeulen
kasperpeulen marked this pull request as ready for review October 20, 2026 17:20
@kasperpeulen kasperpeulen added ci:normal Run our default set of CI jobs (choose this for most PRs). and removed ci:daily Run the CI jobs that normally run in the daily job. labels Oct 21, 2026
@kasperpeulen
kasperpeulen merged commit bc2ca7c into next Oct 21, 2026
304 of 313 checks passed
@kasperpeulen
kasperpeulen deleted the kasper/vite-config-windows-test branch October 21, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA. (e.g. documentation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants