Summary
The web browser test suite can fail when Vite discovers and optimizes react-dom/client after tests have already started. Vitest then reports an unexpected reload and can fail to dynamically import test modules during the reload.
Impact
Unrelated PRs can fail the required bun run --cwd apps/web test:browser CI step even when their changes do not touch the web browser test path. One observed failure imported several browser test files successfully, then Vite logged new dependencies optimized: react-dom/client, reloaded the test session, and src/components/ChatView.browser.tsx failed to import test/wsRpcHarness.ts.
Expected Behavior
Browser tests should start with all required shared dependencies pre-optimized so Vite does not reload the test session mid-run.
Notes
Vitest explicitly recommends adding dependencies that trigger mid-run optimization to optimizeDeps.include for stable browser tests.
Summary
The web browser test suite can fail when Vite discovers and optimizes
react-dom/clientafter tests have already started. Vitest then reports an unexpected reload and can fail to dynamically import test modules during the reload.Impact
Unrelated PRs can fail the required
bun run --cwd apps/web test:browserCI step even when their changes do not touch the web browser test path. One observed failure imported several browser test files successfully, then Vite loggednew dependencies optimized: react-dom/client, reloaded the test session, andsrc/components/ChatView.browser.tsxfailed to importtest/wsRpcHarness.ts.Expected Behavior
Browser tests should start with all required shared dependencies pre-optimized so Vite does not reload the test session mid-run.
Notes
Vitest explicitly recommends adding dependencies that trigger mid-run optimization to
optimizeDeps.includefor stable browser tests.