Skip to content

chore(frontend): move unit tests to vitest 5.0.1 - #5942

Merged
norman-abramovitz merged 3 commits into
cloudfoundry:developfrom
nabramovitz:norm/chore/vitest-5
Sep 23, 2026
Merged

norman-abramovitz merged 3 commits into
cloudfoundry:developfrom
nabramovitz:norm/chore/vitest-5

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

Replaces #5939, #5940 and #5941, which bump vitest, @vitest/coverage-v8 and @vitest/ui to 5.0.1 separately. Vitest 5 peers the other two at exactly its own version, so none of the three works on its own. They move together here, with the two changes that make the suite run.

Why the dependabot PRs fail

Any of them on its own, or all three together, fails in two layers.

  1. Every spec fails to load. vitest.workspace.setup.ts declares a decorated NgModule. Under vitest 5 the decorator helper is emitted as an import of @oxc-project/runtime/helpers/decorate instead of being inlined, and nothing in the tree provides that package:

    Failed to resolve import "@oxc-project/runtime/helpers/decorate"
      from "src/frontend/vitest.workspace.setup.ts"
    
  2. Each project runs the whole tree. With the import fixed, vitest run --project=git runs 679 files and 486 fail, mostly with No provider found for ResourceLoader. --project itself works: every one of those files is labelled |git|. The problem is that the git project collects the whole tree. Each inline entry in vitest.config.ts extends a package config that sets test.root to its own directory. Vitest 4 honours that. Vitest 5 gives an inline project the root of the file that declares it, so the package's include: ['src/**/*.spec.ts'] resolves from the repo root, and the Angular plugin looks for tsconfig.spec.json at the repo root and compiles no templates. Setting a top-level root inside the package config does not help; it has to be on the inline entry.

Angular 22.1 is not involved. The tests call vitest directly and never go through @angular/build, so its vitest peer range doesn't apply.

Changes

  • chore(frontend): set a root on each vitest project adds root: 'src/frontend/packages/<pkg>' to each of the eight entries. It lands first because it changes nothing under vitest 4, which keeps the next commit a pure dependency change.
  • chore(frontend): move unit tests to vitest 5.0.1 bumps the three packages, keeping each one's existing pin style, and adds @oxc-project/runtime at 0.121.0, the version of the installed oxc-parser.
  • A changelog.d fragment.

Verification

Full bun run test, same machine:

files tests
vitest 4.1.11, develop as-is 666 passed, 2 skipped 3745 passed, 2 skipped
vitest 4.1.11 + root commit 666 passed, 2 skipped 3745 passed, 2 skipped
vitest 5.0.1, no root commit, --project=git 486 of 679 failed 1056 failed
vitest 5.0.1, this branch 666 passed, 2 skipped 3745 passed, 2 skipped
  • make check gate passes on the branch.
  • bun run test:coverage passes on vitest 5, with the same file and test counts and 63.49% statement coverage.
  • vitest --ui starts, and the page and its assets load.
  • No spec uses toMatchSnapshot or toMatchInlineSnapshot, so the @analogjs/vitest-angular/setup-snapshots import, whose stable 2.7.2 still peers vitest ≤ 4, has nothing to affect.

Each inline entry in vitest.config.ts extends a package config that
sets test.root to its own directory. Vitest 4 honours that. Vitest 5
does not: an inline project takes the root of the file that declares
it, so every package's include of src/**/*.spec.ts resolves from the
repo root and matches all 679 specs, and the Angular plugin looks for
tsconfig.spec.json at the repo root and compiles no templates. The
result under vitest 5 is 486 failing files, mostly "No provider found
for ResourceLoader", for any single --project.

Setting root on the entry itself fixes that and changes nothing under
vitest 4: the full suite gives the same 666 passed and 2 skipped files
and 3745 tests before and after. Landing it first keeps the runner
bump a pure dependency change.
Replaces dependabot PRs 5939, 5940 and 5941, which bump vitest,
@vitest/coverage-v8 and @vitest/ui separately. Vitest 5 peers the
other two at exactly its own version, so none of the three is coherent
on its own; they move together here.

@oxc-project/runtime is added at 0.121.0, the version of the installed
oxc-parser. Under vitest 5 the decorator helper for the decorated
NgModule in vitest.workspace.setup.ts is emitted as an import of
@oxc-project/runtime/helpers/decorate instead of being inlined, and
nothing in the tree provided it, so every spec file failed to load.

The per-project root added in the previous commit is the other half.
With both, the full suite matches vitest 4 exactly: 666 passed and 2
skipped files, 3745 passed and 2 skipped tests. test:coverage runs
green and test:ui serves. Angular 22.1 is unaffected: the tests call
vitest directly and never go through @angular/build.

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz
norman-abramovitz merged commit 0b54605 into cloudfoundry:develop Sep 23, 2026
24 checks passed
@nabramovitz
nabramovitz deleted the norm/chore/vitest-5 branch September 23, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants