chore(vitest): upgrade to Vitest 5 and share one preset across package configs - #6473
Draft
kanadgupta wants to merge 12 commits into
Draft
chore(vitest): upgrade to Vitest 5 and share one preset across package configs#6473kanadgupta wants to merge 12 commits into
kanadgupta wants to merge 12 commits into
Conversation
(cherry picked from commit 27d3b1a)
(cherry picked from commit cf1433f)
(cherry picked from commit eb3639b)
(cherry picked from commit 7d294eb)
(cherry picked from commit 25aa3e6)
The 4.x coverage providers crash under Vitest 5 (the istanbul variant fails with "Expected string coverage payload, received object"), which breaks the --coverage.enabled unit and integration CI jobs. The 5.0.0 provider shipped the same day as vitest@5.0.0, so it needs the same minimumReleaseAge exclusion. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Every @effect/vitest 4.0.0-rc.x pins vitest <5, but it only uses the stable entrypoint and the whole unit/integration suite passes on Vitest 5. Record the deliberate override so installs stop warning; drop it once upstream widens the range. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 338843b)
Declaring vitest in the root manifest enabled knip's Vitest plugin for the root workspace. It followed the root config's projects globs and re-analyzed every package's test files as root entries, which misattributed the dependencies of the release scripts referenced from GitHub workflows and failed knip:check with four unused devDependencies. Register the root config as a plain entry instead; package-level plugins already analyze their own configs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 5a0b26f)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 30fa169)
Every TypeScript workspace repeated the same Vitest scaffolding: istanbul coverage, passWithNoTests, the unit/integration/e2e include globs, and, in apps/cli and packages/config, the bun export-condition resolve blocks copied onto every inline project because Vitest 4 did not inherit them. vitest.shared.ts now owns that. definePackageConfig merges the shared defaults, and testProject(kind, overrides) declares one inline project per test kind with the file-suffix convention baked in. Vitest 5 inherits the declaring config into inline projects, so the duplicated resolve blocks and Dockerfile plugin entries are gone. The root config reuses the same run-level defaults and loads each package config as a nested project group. apps/cli-e2e also becomes a nested e2e project so it shows up as '@supabase/cli-e2e (e2e)' from the root and matches a '*(e2e)' filter; its lexicographic sequencer stays a run-level option for standalone runs. Its redundant node_modules exclude is dropped in favour of Vitest's defaults. vite is now an explicit root devDependency because the preset imports its default export-condition lists. Standalone per-package runs, the CI coverage commands, and a root run all collect the same projects and test counts as before. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Adapted while rebasing onto the e2e split: the preset's coverage provider is v8 (develop switched from istanbul in #6470), and testProject knows the e2e-stack sub-kind: the e2e kind excludes *.stack.e2e.test.ts and e2e-stack defaults to serial execution, so the CLI and stack package configs express the split as one testProject call each. runDefaults is typed with `satisfies TestUserConfig` (folded from the follow-up commit). (cherry picked from commit dd07660)
Contributor
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@eeff93a2eb0e82a251632db8371305fa3f2f6989Preview package for commit |
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…a chunked body The gateway forwarded every non-GET request body as a stream, so a DELETE from supabase-js, which carries no body, went to PostgREST as an empty chunked body. Under the Bun HTTP client PostgREST drops that connection, and every native delete surfaced as "Bad gateway: Transport error". The stack package's own e2e never saw it because, until the shared Vitest preset added the bun export condition, its tests resolved @supabase/stack to src/node.ts rather than the src/bun.ts the shipped CLI runs. A request with no transfer-encoding and no (or zero) content-length is now forwarded with an empty body; the unit test asserts the upstream request is not chunked, and the native PostgREST e2e passes again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Stacked on #6472 (PR A). The base is that branch so only PR B's changes show here; retarget to
developonce A merges. Draft withrun-ciso the suite runs; installs will fail with HTTP 451 from the dependency firewall until it releases thevitest@5.0.0tarballs, which is the external blocker for this whole PR.Summary
Second of three PRs from
docs/superpowers/plans/2026-09-04-test-execution-topology.md: the Vitest 5 upgrade, its migration blockers, and one shared preset for every package config. Supersedes #6457 and #6456; their useful commits are cherry-picked here.Vitest 5 at the root.
vitestbecomes a root devDependency and a rootvitest.config.mtsreferences every package config as a nested project group, sobun --bun vitest run --project '*(unit)'from the repo root runs one kind across all workspaces. Projects are named<package> (<kind>), for examplesupabase (e2e-stack). A roottest:vitestscript is a temporary entry point; PR C replaces the script layout.Migration blockers.
@vitest/coverage-v8moves to 5.x: the 4.x providers crash under Vitest 5, which breaks the--coverage.enabledCI jobs. Same-day publish, so it gets the sameminimumReleaseAgeExcludeentry asvitest@5.0.0.@effect/vitest4.0.0-rc.x pinsvitest <5; it runs cleanly on Vitest 5, so apeerDependencyRules.allowedVersionsentry records the override until upstream widens the range.vitestat the root enabled knip's Vitest plugin for the root workspace, which followed theprojectsglobs and re-analyzed every package's tests as root entries, misattributing release-script dependencies and failingknip:check. The root config is registered as a plain knip entry and the plugin stays off at the root..vitest/is ignored (Vitest 5's artifact directory) and one CLI unit test resolves its fixture path fromimport.meta.dirnameinstead ofprocess.cwd(), which differs under a root run.One shared preset.
vitest.shared.tsowns what every package config repeated: coverage,passWithNoTests, console output only from failing tests, the bun export-condition resolution for workspace packages, and the include globs per test kind.definePackageConfigmerges it andtestProject(kind, overrides)declares one inline project per kind, so the stack package's config is now threetestProjectcalls. The preset knows thee2e-stacksub-kind from #6472:e2eexcludes*.stack.e2e.test.tsande2e-stackdefaults to serial execution, so the CLI's split is onetestProjectcall each. Vitest 5 inherits the declaring config into inline projects, so the resolve blocks Vitest 4 forced onto every inline project are gone.apps/cli-e2ebecomes a nestede2eproject so it appears as@supabase/cli-e2e (e2e)from the root; its lexicographic sequencer stays a run-level option for standalone runs.A real bug the preset uncovered, fixed here.
packages/stackexports abuncondition (src/bun.ts) and adefault(src/node.ts). Its own tests never had the bun condition, so they exercised the Node implementation while the shipped CLI runs the Bun one. With the preset they switch tosrc/bun.ts, and the native PostgREST e2e failed on every DELETE withBad gateway: Transport error. Cause: the API proxy forwarded every non-GET body as a stream, so a body-less DELETE from supabase-js reached PostgREST as an empty chunked body, which it drops under the Bun HTTP client. The proxy now sends an empty body when the incoming request has no transfer-encoding and no or zero content-length; a unit test asserts the upstream request is not chunked, and the native e2e passes again. This is a product fix in the gateway, hence thefix(stack)commit.Package configs remain dual-role: the run root for
pnpm test:unitinside a package, and one member of the root run's project list. Standalone per-package runs and the root run collect the same projects and test counts as #6472.