Repository navigation
Move to Vitest 5 and @cloudflare/vitest-plugin 1.4.0 - #19
Conversation
Vitest 5 enables the on-disk module cache by default, and the plugin hands workerd cache file paths it cannot read, so the worker project turns fsModuleCache off until the plugin reads the cache in the pool.
bcaf9a6 to
3e9c16f
Compare
ReviewIndependent review by a Claude Opus 5.5 reviewer agent at f83973e: |
Why
The phase-1 plan specified Vitest 5, but the project was pinned to
Vitest ^4.1 because
@cloudflare/vitest-plugin1.3.7, the newestversion the release-age gate allowed at the time, supported only
Vitest 4 and its workerd pool would not start under 5.
@cloudflare/vitest-plugin1.4.0 declaresvitest: ^4.1.0 || ^5.0.0,so the pin can move.
What changed
vitestmoves from ^4.1.11 to ^5.0.4 and@cloudflare/vitest-pluginfrom ^1.3.7 to ^1.4.0. The lockfile drops the plugin's old private
copies of wrangler 4.148.0, esbuild 0.28.1 and zod 4.4.3, and the
@vitest/*packages Vitest 5 no longer splits out. Plugin 1.4.0depends on exactly wrangler 4.149.0 and miniflare
5.20261006.1-alpha, which the existing release-age exclusions in
pnpm-workspace.yamlalready cover; no exclusion was added.fsModuleCache: false. Vitest 5 turnsthe on-disk module cache on by default and hands the runner paths to
cached transformed modules; workerd cannot read the host filesystem,
so all three worker suites failed with
readAll: no such file or directory. The upstream fix is [vitest-plugin] Fix filesystem module caching cloudflare/workers-sdk#16163, stillopen; the issue filed for this failure, #16237, was closed as a
duplicate of the report on #16132, not because a fix shipped. Core
and client keep the cache. The config comment and a new
docs/DECISIONS.mdrow say to drop the override once a pluginrelease reads the cache in the Node pool, and a new
TODO.mdentrytracks that.
docs/DECISIONS.mdrow on--passWithNoTests=falseno longernames Vitest 4; Vitest 5 also fails on empty collection by default.
Vitest 5 migration guide were checked against the tests: the only
mocks are per-test
vi.fn()(unaffected byclearMocksnowdefaulting on), and nothing uses
toThrow(''),sequential,expect.poll, unawaitedresolves/rejects,bench, worker ids orremoved entrypoints.
Type: tooling
Resolves TODO: bump-vitest-to-five
Files TODO: drop-worker-fs-module-cache-override
Validation
bash scripts/check.shbefore the bump: pass. 20 files, 129 tests:core 15 files / 104 tests, worker 3 / 19, client 2 / 6 (per-project
counts from
bash scripts/test.sh --reporter=json).and failed with the
readAllerror, on cold and warm caches; coreand client passed (110 tests).
fsModuleCache: falseon the worker project, after deletingnode_modules/.vitest-cache: core 15 / 104, worker 3 / 19,client 2 / 6, all passing, identical to the baseline.
bash scripts/test.sh test/does-not-exist: exit 1, so emptycollection still fails the gate.
pnpm install --frozen-lockfile: lockfile up to date.bash scripts/check.sh(fmt-check, lint, typecheck, test): pass.bash scripts/build.sh: pass.bash docket/scripts/check-queues.sh --strict: no errors.pnpm dev, and coverage (the project hasno coverage run; 🐛 BUG: vitest-plugin coverage shim doesn't handle __vitest_stopV8Coverage under vitest 5 cloudflare/workers-sdk#16238 reports a separate
plugin bug with V8 coverage under Vitest 5).