Skip to content

[EPIC] Migrate the unit suite off Karma — 192 specs remaining #403

Closed
7 of 7 issues completed
Closed

Description

@Aman-Mittal

Summary

Karma is deprecated and @angular/build:karma goes with it. The groundwork is done — a Vitest runner, a codemod, and a CI ratchet that stops the Karma set growing — so what remains is moving the specs, batch by batch.

This is the best-stocked source of good first issues in the repo right now. Each sub-issue is a self-contained batch: run one command, run the suite, commit. No design decisions, no domain knowledge, and the result is verifiable by anyone.

How a batch works

# 1. Convert. The codemod does the dialect swap AND the .spec.ts -> .test.ts rename.
node scripts/codemod-jasmine-to-vitest.mjs src/app/features/<area>/**/*.spec.ts

# 2. Run the migrated suite.
npm run test:unit

# 3. Re-record the ratchet baseline.
node scripts/check-test-runner.mjs --write

# 4. The rest of the usual checks.
npm run lint:prune && npm run format && npm test -- --watch=false

npm run check:test-runner prints how many are left.

What the codemod handles, and what it doesn't

It converts dialect — vi.fn() for jasmine.createSpy(), .mockReturnValue() for .and.returnValue(), toBe(true) for toBeTrue(), SpyObj<T>/createSpyObj<T>() from src/app/testing/mocks.ts for the Jasmine equivalents.

It skips whole files that use fakeAsync, tick, flush, done() callbacks, jasmine.clock or the object form of createSpyObj, and tells you which. Those carry zone or callback semantics rather than a spelling, and they are collected in a separate issue that is explicitly not a first issue.

Remaining work by area

Area Mechanical Needs a person
features/products 38 1
features/system 32 0
features/accounting 15 0
features/clients 13 0
features/loans 13 0
features/organization 10 0
features/working-capital 10 0
features/spm 5 0
17 smaller areas 23 3
core 1 11
shared 2 3
Total 173 19

Ground rules

  • One area per PR. A 192-file diff is unreviewable; a 15-file one is not.
  • The suite must stay arithmetically whole — Karma total + Vitest total should not drop. State both counts in the PR.
  • Do not "improve" a spec while migrating it. A migration diff that also changes assertions cannot be reviewed as either.

Background, and the open question about Vitest browser mode: DOCS/adr/0004-vitest-migration.md.

Activity

  1. Aman-Mittal commented on Aug 19, 2026

    @Aman-Mittal
    MemberAuthor

    Reopened — this was closed in error when #408 merged. The PR body carried a Closes #403 keyword it should not have had; the groundwork landed, but the migration this epic tracks has barely started.

    Actual state: 30 of 222 specs migrated. 192 still on Karma, 0 of 7 sub-issues done.

    $ npm run check:test-runner
    ✓ No new Karma specs. 192 remaining (14% migrated).
    

    What #408 actually delivered

    The tooling, not the migration:

    • @angular/build:unit-test wired with the Vitest runner (npm run test:unit), Karma narrowed to **/*.spec.ts
    • scripts/check-test-runner.mjs + karma-baseline.json — the CI ratchet that stops the Karma set growing
    • scripts/codemod-jasmine-to-vitest.mjs — converts 187 of the 215 remaining specs
    • src/app/testing/mocks.ts, src/testing/vitest-setup.ts, vitest.config.ts
    • 30 specs migrated as proof the toolchain works end to end, including Ionic component rendering: Vitest 270 tests, Karma 921, total 1191 — unchanged, so nothing was lost

    What remains

    All seven sub-issues, unchanged: #404 (system, 32), #405 (accounting, 15), #406 (clients + loans, 26), #407 (organization + working-capital, 20), #409 (products, 39), #410 (the 19 fakeAsync/flush specs), #411 (17 smaller areas, 28).

    This epic should close when check:test-runner reports 0 remaining and the Karma builder is removed from angular.json — not before.

  2. zhangxinyao88 commented on Aug 26, 2026

    @zhangxinyao88
    Contributor

    Current migration tracker. The counts below are from current main.

    Why this migration exists

    Karma and @angular/build:karma are deprecated upstream. The migration moved the unit suite to Vitest incrementally, preserving test behaviour while the legacy set shrank. The final step was removing the old runner and its temporary migration tooling. See ADR 0004.

    Completed

    • 236 Vitest test files
    • 0 Karma spec files
    • All migration batches landed
    • #479 removed the deprecated runner, direct dependencies, baseline, codemod and temporary CI paths

    #403’s migration work is complete.

    Sub-issues

    Final state

    • npm test runs the Vitest suite
    • Karma/Jasmine configuration and direct dependencies are gone
    • The migration baseline, ratchet and codemod are removed
    • No unit-test files remain on the legacy runner

    Coordination

    There are no remaining migration batches to claim. The epic can now be closed.

  3. zhangxinyao88 commented on Sep 5, 2026

    @zhangxinyao88
    Contributor

    @Aman-Mittal, final verification on current main:

    Could you please close #409, #410, and then this epic? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions