You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace Karma + Jasmine with Vitest for the Angular 21 frontend. Removes a deprecated runner, modernizes the test setup, and keeps texera on the path Angular's tooling team is investing in.
Why now, why Vitest
Karma is deprecated.npm-published deprecation since April 2023; Angular's official builder treats @angular-devkit/build-angular:karma as end-of-life. We are still on karma@6.4.4 + karma-jasmine@5.1.0.
Three options were considered:
Stay on Karma. Increasingly broken on each Angular major (we have already shipped one workaround in karma.conf.js for the Angular --code-coverage injection). Defers the inevitable.
Migrate to Jest. PR Migrate frontend test framework from Karma to Jest #2995 (Nov 2024, closed unmerged) attempted this. Path works, but Angular's Jest support is officially "experimental" and frozen — no further investment from the team. The PR's own checklist captured one pain point that never got resolved: "ignore transformation of ESM modules" — Jest needs transformIgnorePatterns per ESM dependency in node_modules, a recurring tax on every dependency bump.
Migrate to Vitest. Angular's actively-developed test runner path (Angular 19+); ESM-native so the Jest pain point doesn't apply; Vite-powered for fast watch; expect API is Jest-compatible so most matcher / spy code reads identically.
We are choosing option 3 — Vitest — because picking Jest in 2026 inherits Karma's fate in 2-3 years.
Known friction points
frontend/custom-webpack.config.js is webpack-specific. Any test-time aliases / loaders / env-var injection there have to be re-expressed for Vite.
We use Nx (nx.json, @nx/angular) as a thin cache wrapper. The @nx/vitest executor is younger than @nx/jest. Worst case: bypass Nx for the test target and use ng test --use=vitest directly.
73 *.spec.ts files to migrate. Most should be a near-mechanical sweep:
jasmine.createSpy / jasmine.Spy → vi.fn() / Mock from vitest
Coverage: switch karma-coverage (lcov via Karma) to Vitest's coverage (v8 by default). The Codecov upload glob already targets frontend/coverage/**/lcov.info, which Vitest's coverage reporter can produce when configured.
Most of #2995's 3,959 line diff is reusable: removing karma packages, fixing wrong test-file imports (e.g., HttpClient), deleting empty test files. Only the runner config and jest.fn → vi.fn swap differ. Roughly 70–80% of the work transfers.
Plan
Land in stages, smallest first:
Scaffolding PR (this issue's first deliverable): add Vitest deps + config, switch the ng test target, remove Karma deps and karma.conf.js. Goal: existing 73 spec files run under Vitest, even if some need shims.
Mechanical migration sweeps: batch updates for jasmine.* → vi.* patterns, in chunks small enough to review.
Task Summary
Replace Karma + Jasmine with Vitest for the Angular 21 frontend. Removes a deprecated runner, modernizes the test setup, and keeps texera on the path Angular's tooling team is investing in.
Why now, why Vitest
Karma is deprecated. npm-published deprecation since April 2023; Angular's official builder treats
@angular-devkit/build-angular:karmaas end-of-life. We are still onkarma@6.4.4+karma-jasmine@5.1.0.Three options were considered:
karma.conf.jsfor the Angular--code-coverageinjection). Defers the inevitable.transformIgnorePatternsper ESM dependency innode_modules, a recurring tax on every dependency bump.expectAPI is Jest-compatible so most matcher / spy code reads identically.We are choosing option 3 — Vitest — because picking Jest in 2026 inherits Karma's fate in 2-3 years.
Known friction points
frontend/custom-webpack.config.jsis webpack-specific. Any test-time aliases / loaders / env-var injection there have to be re-expressed for Vite.nx.json,@nx/angular) as a thin cache wrapper. The@nx/vitestexecutor is younger than@nx/jest. Worst case: bypass Nx for the test target and useng test --use=vitestdirectly.*.spec.tsfiles to migrate. Most should be a near-mechanical sweep:jasmine.createSpy/jasmine.Spy→vi.fn()/MockfromvitestspyOn(obj, 'method').and.returnValue(...)→vi.spyOn(obj, 'method').mockReturnValue(...)jasmine.clock()→vi.useFakeTimers()expect(x).toEqual(y)etc. unchangedkarma-coverage(lcov via Karma) to Vitest's coverage (v8 by default). The Codecov upload glob already targetsfrontend/coverage/**/lcov.info, which Vitest's coverage reporter can produce when configured.Recoverable from PR #2995
Most of #2995's 3,959 line diff is reusable: removing karma packages, fixing wrong test-file imports (e.g.,
HttpClient), deleting empty test files. Only the runner config andjest.fn→vi.fnswap differ. Roughly 70–80% of the work transfers.Plan
Land in stages, smallest first:
ng testtarget, remove Karma deps andkarma.conf.js. Goal: existing 73 spec files run under Vitest, even if some need shims.jasmine.*→vi.*patterns, in chunks small enough to review.transformIgnorePatterns-equivalent ESM issues that PR Migrate frontend test framework from Karma to Jest #2995 left open.frontend/karma.conf.jsreferences in.github/workflows/build.ymland Codecov upload paths if needed.References
Task Type