Repository navigation
Description
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:karma as end-of-life. We are still on [email protected] + [email protected].
Three options were considered:
- Stay on Karma. Increasingly broken on each Angular major (we have already shipped one workaround in
karma.conf.jsfor the Angular--code-coverageinjection). 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
transformIgnorePatternsper ESM dependency innode_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;
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.- We use Nx (
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. - 73
*.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. unchanged
- Coverage: switch
karma-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 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 testtarget, remove Karma deps andkarma.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. - Cleanup PR: delete empty / dead spec files surfaced during the sweep, fix the
transformIgnorePatterns-equivalent ESM issues that PR Migrate frontend test framework from Karma to Jest #2995 left open. - CI rewire: update
frontend/karma.conf.jsreferences in.github/workflows/build.ymland Codecov upload paths if needed.
References
- PR Migrate frontend test framework from Karma to Jest #2995 — closed Karma → Jest attempt (preserved for diff context)
- Karma deprecation: https://www.npmjs.com/package/karma
Task Type
- Refactor / Cleanup
- DevOps / Deployment / CI
- Testing / QA
- Documentation
- Performance
- Other
Activity
Yicong-Huang commentedon May 3, 2026
I will handle this issue as it is a large framework change.
chore(frontend): mechanical Jasmine → Vitest sweep across 73 spec files
chore(frontend): exclude specs that need follow-up; CI green at 109 p…
feat(frontend): enable more tests w/o source changes — stub empty spe…
anyannotations in spec files #4867feat(frontend): scaffold Vitest test runner (Karma → Vitest, step 1)
chore(frontend): mechanical Jasmine → Vitest sweep across 73 spec files
chore(frontend): exclude specs that need follow-up; CI green at 109 p…
feat(frontend): enable more tests w/o source changes — stub empty spe…
chore(frontend): re-enable previously excluded specs that pass under …
test(frontend): unblock 7 specs from jsdom (#4950)
test(frontend): add Vitest browser mode and re-enable workflow-editor…
Yicong-Huang commentedon May 11, 2026
done!
test(frontend): unblock 7 specs from jsdom (apache#4950)
test(frontend): add Vitest browser mode and re-enable workflow-editor…