← Back to list

Jasmine & Karma

What is Jasmine?

Puja Agarwal · 2026-01-03 16:38 · 0 claps · 0.8 min read
#unit-testing-tools #unit-test-framework #unit-testing #jasmine #karma
Open on Medium ↗

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 suite
  • it() → test case
  • expect() → 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