Skip to content

Upgrade to Vitest 5 (blocked on libnest) #1626

Closed

Description

@joshunrau

vitest, @vitest/browser and @vitest/coverage-v8 are held at 4.1.11 in the root package.json by the dependency update on the deps branch. The newest release eligible under the repo's 7-day minimumReleaseAge on 2026-10-04 was 5.0.2.

Why it was not upgraded

@douglasneuroinformatics/libnest@9.0.0 peers vitest 4.x, and the API tests depend on libnest at runtime:

  • apps/api/vitest.config.ts:3 imports @douglasneuroinformatics/libnest/testing/plugin.
  • The API specs import MockFactory and MockedInstance from @douglasneuroinformatics/libnest/testing.

What is required

  1. A libnest release that peers vitest ^4 || ^5.
  2. In this repo, work through the Vitest 5 migration guide:
    • clearMocks now defaults to true.
    • vi.mock and vi.hoisted throw when called outside the top level.
    • Config lookup no longer walks up parent directories.
    • testNamePattern matching changed, and worker IDs now start at 1.
    • None of the removed entry points (vitest/coverage, vitest/reporters) are imported here.
  3. Run pnpm test and pnpm exec vitest list --filesOnly to confirm every project is still collected.

Activity

  1. added
    Priority: Low
    Difficulty: Medium
    Chore
    Area: Infrastructure
    Upstream
    on Oct 5, 2026
  2. joshunrau commented on Oct 26, 2026

    @joshunrau
    CollaboratorAuthor

    No longer blocked upstream. 3f86b10, the first commit on open PR #1660, does this upgrade. But #1660 conflicts with main, and merging it as written would not close this issue (see Landing). @vitest/browser left the root package.json in 08a5736, so only vitest and @vitest/coverage-v8 move (package.json:43, :58).

    Coupled to #1624

    @douglasneuroinformatics/libnest@10.0.0 (published 2026-10-06) peers vitest: "5.x", not ^4 || ^5. It also peers @nestjs/* ^12.0.0 and reflect-metadata ^0.2.2. So Vitest 5 and NestJS 12 are one upgrade, and 3f86b10 does both. Close this together with #1624.

    What the checklist missed

    The change that actually breaks this repo is not on the list. All 21 project configs merge the root default export (for example apps/api/vitest.config.ts:7), and that export carries projects (vitest.config.ts:34). Vitest 5 reads a projects field in a referenced config as nested projects (migration guide, "Referenced Config Files Can Define Their Own Projects"), so every run stops before it collects a file. 3f86b10 exports a named baseConfig (include and watch) from the root config, layers coverage and projects on top of it in the default export with mergeConfig, and switches the 21 configs to import { baseConfig }. A package's own test script then works, so the commit also rewrites step 6 of add-vitest-project.md.

    The rest of the list needs no change here or is already handled:

    • No vi.mock or vi.hoisted call is nested, and nothing uses testNamePattern, VITEST_WORKER_ID or VITEST_POOL_ID.
    • clearMocks broke two tests that assert on calls made at import time or in beforeAll: packages/serve-instrument/src/__tests__/client.test.tsx and apps/gateway/src/server/__tests__/server.development.test.ts. Both now copy those calls in beforeAll.
    • Coverage now counts ?? as a branch. 3f86b10 adds a test to apps/web/src/utils/__tests__/series-overview.test.ts for its ?? '' fallbacks. main has added no ?? since build: upgrade dependencies held back by breaking changes #1660 branched.
    • Reporters write to .vitest/, which the commit adds to .gitignore.

    Landing

    The Upstream label no longer applies: libnest 10 has shipped, and the remaining work is in this repo.

    Triage note written with Claude Code. Code references point at main @ d86740e.

  3. removed
    Upstream
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: InfrastructureChoreDifficulty: MediumPriority: Low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions