Karma
01 / 02

A Real-Browser Test Runner, Not a Framework

A Real-Browser Test Runner, Not a Framework

Runner vs. Framework

Karma launches real browsers (or headless variants) to execute JavaScript tests and reports results — it's a test runner, not an assertion framework. It's paired with a separate testing framework (Jasmine, Mocha) that provides the actual describe/it syntax and assertions; Karma is framework-agnostic via adapter plugins for whichever one a project uses.

Origins in AngularJS

Karma was created by the AngularJS team to run unit tests against real browser environments — Angular's heavy DOM manipulation and browser API usage needed genuine browser fidelity rather than a purely simulated environment. For a long time, Karma+Jasmine was the Angular CLI's default `ng test` setup.

Configuration & Cross-Browser Runs

module.exports = function (config) {
  config.set({
    frameworks: ['jasmine'],
    browsers: ['ChromeHeadless', 'FirefoxHeadless'],
    reporters: ['progress', 'coverage'],
    autoWatch: true,
  })
}

karma.conf.js specifies browsers to launch, the testing framework, file patterns, and reporters. Running the same suite across multiple real browser engines (Chrome, Firefox, Safari) catches cross-browser compatibility bugs a single-browser test run would miss — especially valuable for public-facing applications with a broad, uncontrolled user base whose actual browser mix the team doesn't control.

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free