Repository navigation
Record what a browser-mode test loaded from the Vite module graph, so --changed skips browser tests whose inputs did not change - #18
Conversation
… --changed can skip it Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
… graph, rather than an empty one --changed would trust Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…s node_modules, and a repo path holding /vitest/dist/ is a user module Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>


Feature + tests — a browser-mode test (
test.browser.enabled) now reruns under--changedonly when a module it loaded changed, instead of on every run. Vitest's own--changedgets the same records, so plainvitest --changedbenefits too.Problem
@vitest/browsernever callsonTestModuleDependencies, sodependencies.jsonholds no record for a browser test file. Vitest'sRecordedModulesResolvertreats a file without a record as "always runs", and the plugin's snapshot cannot override that. For a repo such as t3code'sapps/web(216 browser test files beside 356 node ones) the browser half of the suite gets no savings.Record the browser's module graph in the plugin
The project's Vite client environment transformed every module the browser fetched, so its module graph is the record the node worker would have reported. In
SnapshotRecorder.onTestModuleEnd, for a browser project only,recordBrowserDependencies(newsrc/browser.ts) walksproject.vite.environments.client.moduleGraphfrom the test file and the project'ssetupFilesoverimportedModules, keeps each node'sfile(virtual modules like/@vitest/...have none; vitest's owndist/is dropped, as the node collector does), and hands the list to the same call the worker RPC makes:_dependenciesis@internal; when a future vitest no longer exposes it the plugin warns once and browser tests fall back to always running (today's behavior).Vitest's
resolveFilesthen applies its usual filter (absolute, notnode_modules) and, with the module runner on, followstransformResult.depstoo, so the record matches a node project's shape:Evidence
test/fixture-browseris a two-file browser project (Playwright, headless Chromium) with a shared module and asetupFilesentry that imports its own module.--changedsrc/lib/dom.tsdomsrc/lib/math.tsmathsrc/lib/shared.ts(imported by both)src/lib/setup-lib.ts(viasetupFiles)CI and the release workflow install Chromium (
npx playwright install --with-deps chromium) for this fixture.Risks
cache._dependencies.record; a rename degrades to today's always-run with a warning, never to a wrong skip.fetch('/fixture.json')) do not pass through the module graph and are not recorded; the README caveat says so and points to thedependenciesoption.@vitest/browser-playwrightandplaywrightjoindevDependencies(test-only); CI now downloads Chromium.Link to Devin session: https://app.devin.ai/sessions/bd00ad706b5c470c88901f0de1d26deb
Open in Devin Desktop: https://app.devin.ai/desktop/session/bd00ad706b5c470c88901f0de1d26deb?variant=devin
Requested by: @max-blacksmith
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.🟢 Devin Review found nothing to fix · View findings · Follow Devin's work