Skip to main content

Test Runners: Jasmine and Karma, Vitest and Modern Testing Practice

Learn Test Runners: Jasmine and Karma, Vitest and Modern Testing Practice (Phase 13 · Testing and Deployment (Production), Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Jasmine and Karma (the classic setup) • Jasmine is the test framework: describe , it , beforeEach , expect(...).toBe/toEqual/toContain/toThrow , spies ( jasmine.createSpyObj , spyOn ). Karma is the runner that launches real browsers (Chrome) and reports results. ng test runs them in watch mode. • Generated *.spec.ts files sit next to the code. Run once for CI: ng test --watch=false --browsers=ChromeHeadless --code-coverage . • Karma is in maintenance/deprecated status ; new Angular projects are moving to Vitest (stable in recent versions) or Jest.

More lessons in Phase 13 · Testing and Deployment (Production)