Jasmine & Karma
What is Jasmine?
Jasmine & Karma
What is Jasmine?
Jasmine is a testing framework.
👉 It is used to:
- Write test cases
- Describe test behavior in readable English
- Provide assertions (expectations)
Jasmine gives you:
describe()→ test suiteit()→ test caseexpect()→ assertion- Spies (
spyOn) → mock functions
What is Karma?
Karma is a test runner.
👉 It is used to:
- Run the Jasmine tests
- Launch browsers (Chrome, Headless Chrome, Firefox)
- Watch files and re-run tests automatically
- Show test results
Karma does not write tests. It only executes them.
Interview line:
Karma runs the tests written using Jasmine in real browsers.
How they work together (important)
Angular Code ↓ Jasmine (writes tests) ↓ Karma (runs tests in browser) ↓ Test Results
Angular context (very important for interviews)
- Angular CLI comes with Jasmine + Karma by default
ng test:- Uses Karma
- Executes Jasmine tests
- Runs tests in real browser environment
One-paragraph interview answer (use this 🔥)
Jasmine is a testing framework used to write unit tests with readable syntax and assertions. Karma is a test runner that executes these Jasmine tests in real browsers, watches file changes, and reports results. In Angular, Jasmine and Karma work together to provide a complete unit testing setup.
❓ Can Karma work without Jasmine?
➡️ Yes, Karma can run tests written in Jest, Mocha, etc.
메타데이터
- post_id
- 8d7cd91596e1
- slug
- jasmine-karma-8d7cd91596e1
- url
- https://medium.com/@puja_agarwal/jasmine-karma-8d7cd91596e1
- canonical_url
- https://medium.com/@puja_agarwal/jasmine-karma-8d7cd91596e1
- author_url
- https://medium.com/@puja_agarwal
- status
- ok
- fetched_at
- 2026-08-06 23:40:16