Migrate unit tests from Jasmine/Karma to a modern stack

Aperta
#6,173 3 commenti 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@alexandrevryghem ci sta già lavorando.

Dal 2/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

claimed: Atmire code task dependencies needs analysis testing framework

Is your feature request related to a problem? Please describe.

Upgrade to Angular v18 was finalized in DSpace 9.0 (DSpace/dspace-angular#3304). However, Jasmine/Karma is still used for unit tests but, as noted in the issue, Karma is deprecated.

Angular v21 declared stable support for Vitest. This is also the Angular team's default choice for new projects in v21+ (moreover, Angular team also provided a guide on Migrating from Karma to Vitest, so the migration can be semi-automated.)

I'd like us to discuss and plan a migration away from Karma to a modern test runner. From what I can see, the most commonly mentioned options are:

  • Vitest (default in Angular >=v21)
  • Jest (has been around longer)
  • Web Test Runner (runs tests in a real browser rather than Node/jsdom)

Vitest and Jest are both a test runner and a testing library, so they replace both Karma + Jasmine stack. Web Test Runner replaces only Karma (uses bult-in Mocha framework support, but has Jasmine adapter web-test-runner-jasmine).

Also, check out Vitest's Comparisons with Other Test Runners page.

What about Jasmine? Cypress?

Just to avoid confusion: Karma is only the test runner (it launches the browser and reports results). Jasmine is the testing framework we actually write tests with (spyOn etc.).

Both Vitest and Jest support Jasmine-style syntax (and maintain compatibility with most Jasmine functions)

We also use Cypress as the e2e tool (so it's not related to unit tests)

Describe the solution you'd like

This ticket is to discuss and plan a migration away from Karma.

Describe alternatives or workarounds you've considered

We are currently still using Karma via @angular-devkit/build-angular and @angular-builders/custom-webpack:karma. This works for now, but it depends on a deprecated package

Changing the unit test runner while on Angular v20 could make a future v21 upgrade smoother

Additional information

Karma/Jasmine and Angular Timeline
  • Angular v16 declared that Karma was deprecated.
    • This version added experimental support for Jest, and Web Test Runner [source]
  • Angular v20 added experimental support for Vitest [source]
  • Angular v21 declared Vitest as the primary test runner (and stable), replacing Karma [source]

Vitest has gained significant traction recently. According to npm trends, Vitest downloads surpassed Jest around April 2026, and now seem to be 2x higher (Jest was first published in NPM 15 years ago, Vitest 5 years ago).

Questions for the Community
  • Any strong opinions (for or against) any particular test runner?
  • Any other alternatives we should consider?
  • Has anyone already migrated a large Angular project from Karma? If so, what challenges did you face?
  • Does anyone have experience with Vitest in a large Angular monorepo?
  • Are there any DSpace-specific testing needs that might complicate migration?
References

Additional sources not directly mentioned in this issue:

Lingua principale
TypeScript
Stelle
180
Fork
577
Merge medio
2g 1h
PR unite (30g)
100

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DSpace/dspace-angular

Tutte le issue di DSpace/dspace-angular

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.