When to Move an Angular Test Suite to Vitest

Vitest is the default test runner since Angular v21 (November 2025), but existing Karma/Jasmine suites deserve a migration filter. The official migration docs are explicit: 'Migrating an existing project to Vitest is considered experimental.' Doug Parker had announced Karma deprecation back in April 2023; the path has been long.

Default is not the same as mandate

For new Angular CLI projects, Vitest is the current default. That is a strong signal about the direction of Angular testing. It is not the same thing as saying every existing Karma/Jasmine suite should be migrated in one branch.

A test runner migration is successful only if the team trusts the result afterward. If the migration makes CI faster but nobody believes the failures or the passes, the project lost signal.

The first slice matters

CandidateGood first slice?Why
Pure pipesYesLow DOM dependency and easy assertion parity.
Services without browser globalsYesFast feedback with simple setup.
Validation helpersYesUseful for forms without UI complexity.
Small componentsMaybeGood if they avoid overlays, animations, and complex timers.
Overlay, canvas, drag/drop, browser-heavy specsLaterThey test the hardest migration path first.

What to run first

The first migration branch should prove configuration, CI behavior, and a small set of test patterns. Do not start by deleting Karma from a large application.

The official migration path includes manual configuration work, optional browser mode, and an experimental schematic for Jasmine-to-Vitest refactoring. That means every generated diff still needs review.

Small Vitest pilot commandsbash
npm install --save-dev vitest jsdom
ng test --no-watch
ng g @schematics/angular:refactor-jasmine-vitest --include=src/app/orders

What would make me wait

Wait if the suite depends heavily on fakeAsync, flush, browser-only APIs, custom Karma launchers, or global test setup nobody currently understands. Those are not blockers forever, but they are a bad place to start.

The official Vitest migration guide is explicit that Zone.js based helpers such as fakeAsync, flush, and waitForAsync are not supported. New examples in this series should prefer native async, observable assertions, or Vitest timers unless they are clearly labeled as Karma/Jasmine code.

The right proposal is not 'move all tests to Vitest'. It is 'move this slice, compare CI time and failure quality, document unsupported patterns, then decide the next slice'.

Reusable artifact

Vitest pilot acceptance criteria

  • One small slice migrated and reviewed.
  • CI runtime compared before and after.
  • Known unsupported patterns documented, especially Zone.js testing helpers.
  • Browser-mode need decided explicitly.
  • Karma kept until the team trusts the replacement path.

Sources checked

Angular Vitest Migration Kit

Migrating this suite to Vitest?

The Angular Vitest Migration Kit sizes your migration by risk, then packages the config, the fakeAsync cookbook, an AI-agent skill, and a runnable demo. The conversions in this article, done for you.

Verified on Angular 21.2.14 / Vitest 4.1.8. Includes the migration estimator, the PDF guide, copy-paste config, an AI-agent skill, and a runnable demo.

Get the kit · US$15 →

André Ramosavailable for remote roles, UTC−3Get in touch →

Related

Guide · 8 min

Component Testing in Angular with Vitest: TestBed, jsdom, and Browser Mode

How Angular component tests actually behave under Vitest: TestBed is unchanged, the DOM is jsdom (no layout, no real CSS), and the specs that need a real browser are the ones to move to Vitest browser mode.

Read article →

Guide · 8 min

Mocking Services and HttpClient in Angular Vitest: vi.fn, Spies, and DI

The Jasmine-to-Vitest spy map for Angular tests (vi.fn, vi.spyOn, mockReturnValue), why a DI provider mock beats vi.mock for services, and how HttpTestingController still works with provideHttpClientTesting.

Read article →

Guide · 7 min

Karma to Vitest in Angular: The Config That Actually Runs

What the Angular v21 Vitest test target actually is (one line), where polyfills and styles come from, the install that drops Karma, and the few options worth adding.

Read article →