Repository navigation
vp test fails with @cloudflare/vitest-plugin while vitest run passes (1.8.0, again after #1076)#3619Description
Describe the bug
With @cloudflare/vitest-plugin (the renamed @cloudflare/vitest-pool-workers), vp test run fails before any test is collected, while vitest run in the same project, with the same config, passes. This looks like #1076 again, on vite-plus 1.8.0 and Vitest 5.1.1, with a fresh lockfile.
Error: Vitest failed to find the current suite. One of the following is possible:
- "vitest" is imported directly without running "vitest" command
...
Test Files 1 failed (1)
Tests no tests
It fails the same way whether the test imports from vite-plus/test or from vitest. In a larger project the error was Vitest failed to find the runner and TypeError: Cannot read properties of undefined (reading 'config'), as in #1076.
After a fresh pnpm install there are two copies of vitest@5.1.1 in node_modules/.pnpm, differing only in peers (one with vite@8.4.0, one with @voidzero-dev/vite-plus-core). My guess is that the plugin's worker gets one and vp's runner the other. pnpm dedupe does not change that.
Reproduction
Six small files, all inline below (no repository).
Steps to reproduce
package.json
{
"name": "vp-cloudflare-vitest-plugin-repro",
"private": true,
"type": "module",
"scripts": {
"test": "vp test run",
"test:vitest": "vitest run"
},
"devDependencies": {
"@cloudflare/vitest-plugin": "1.8.4",
"@cloudflare/workers-types": "^5.20261008.1",
"typescript": "^6.0.3",
"vite-plus": "1.8.0",
"vitest": "5.1.1",
"wrangler": "^4.148.0"
},
"packageManager": "pnpm@10.26.2"
}pnpm-workspace.yaml (what vp migrate writes)
catalog:
vite: npm:@voidzero-dev/vite-plus-core@8.3.8001
vitest: 5.1.1
vite-plus: 1.8.0
overrides:
vite@*: 'catalog:'
vitest@*: 'catalog:'
peerDependencyRules:
allowAny:
- vitest
allowedVersions:
vitest: '*'vite.config.ts
import { cloudflareTest } from "@cloudflare/vitest-plugin";
import { defineConfig } from "vite-plus";
export default defineConfig({
plugins: [cloudflareTest({ wrangler: { configPath: "./wrangler.jsonc" } })],
test: { include: ["test/**/*.test.ts"] },
});wrangler.jsonc
{ "name": "repro", "main": "src/index.ts", "compatibility_date": "2026-11-01" }src/index.ts
export default {
async fetch(): Promise<Response> {
return Response.json({ ok: true });
},
};test/index.test.ts
import { exports } from "cloudflare:workers";
import { expect, test } from "vite-plus/test";
test("responds", async () => {
const response = await (exports as any).default.fetch("https://example.com/");
expect(await response.json()).toEqual({ ok: true });
});Then:
pnpm install
pnpm exec vp test run # fails: no tests
pnpm exec vitest run # passes: 1 testSystem Info
vp v1.8.0
vite v8.3.8
rolldown v1.2.19
vitest v5.1.1
@cloudflare/vitest-plugin 1.8.4
wrangler 4.169.1
pnpm 10.26.2
macOS (arm64), Node 22.23.2 (also on 25.9.0)Used Package Manager
pnpm
Logs
FAIL test/index.test.ts [ test/index.test.ts ]
Error: Vitest failed to find the current suite. One of the following is possible:
- "vitest" is imported directly without running "vitest" command
- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
- "vitest" is imported inside Vite / Vitest config file
- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues
❯ test/index.test.ts:5:31
Test Files 1 failed (1)
Tests no tests$ ls node_modules/.pnpm | grep '^vitest@'
vitest@5.1.1_@vitest+browser-preview@5.1.1_@vitest+ui@5.1.1_vite@8.4.0_esbuild@0.28.2_
vitest@5.1.1_@vitest+browser-preview@5.1.1_@vitest+ui@5.1.1_vitest@5.1.1__@voidzero-dev_59ab306aace139a99f40a74aba5aacf8
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Target date
Start date
Activity
gxcsoccer commentedon Nov 30, 2026
I found the cause. It is in the dependency setup that
vp migratewrites, not in the Cloudflare plugin.pnpm-workspace.yamlhasoverrides: vite@*: npm:@voidzero-dev/vite-plus-core@8.3.8001.The project has no direct
vitedependency.vitest'svitepeer is auto-installed by pnpm, and the override does not apply to it, so the lockfile has the realvite@8.4.0:That gives two
vitest@5.1.1instances: the project's (and@cloudflare/vitest-plugin's) peersvite@8.4.0, andvite-plus's peers@voidzero-dev/vite-plus-core:vp testsets the runner up in vite-plus's instance. Inside workerd, the plugin resolvesvitestrelative to the test file and gets the project's instance, which has no runner.Workaround, verified in the repro above: declare
vitefrom the catalog so that the override applies:After
rm -rf node_modules pnpm-lock.yaml && pnpm installthere is onevitest@5.1.1, and bothvp test runandvitest runpass.Possible fix: when
vp migratesees that a package uses Vitest but has no directvitedependency, it could addvite: catalog:.vitePeerDependencyRuleRequiredinpackages/cli/src/migration/migrator/shared.tsalready covers how pnpm applies the alias override to peers, but not this case, where the peer is auto-installed. Resolvingvitestfrom the running Vitest (ctx.distPath) in the Cloudflare plugin would also avoid the split, but the duplicate install looks like the root cause.voidzero-bot commentedon Nov 30, 2026
Triage failed unexpectedly (attempt 1 of 3).
Run: https://github.com/voidzero-dev/vite-plus/actions/runs/46349739084
I can retry if a new comment provides more information or asks me to try again.
Error: