Guide · Open source
How to use Karma: run JavaScript tests in real browsers
Updated · written with AI from the project's own documentation and checked against our catalogue data
Karma is an open-source tool that runs JavaScript test code inside real web browsers, so you can check that your code behaves correctly where it will actually run. This guide explains what Karma does, how it fits with testing frameworks like Jasmine, Mocha or QUnit, and when it is a sensible choice. It also covers an important caveat: the README states that Karma is deprecated.
Quick start
- 1Check whether Karma fits. Read the deprecation notice and decide whether you are maintaining an existing suite or starting a new project.
- 2Install Node.js. Karma requires Node.js, so make sure it is installed before you set up Karma.
- 3Get the source. Clone the repository with git clone https://github.com/karma-runner/karma if you want the source code.
- 4Follow the installation guide. Use the official installation page linked from the README for the package-based setup steps.
- 5Add a framework adapter. Install an adapter such as karma-jasmine, karma-mocha or karma-qunit, because Karma does not include a test framework.
- 6Configure browsers and files. Use the configuration guide to choose browsers and the files Karma should load.
- 7Run and troubleshoot. Run your tests locally or in CI, and use the FAQ, mailing list or Gitter when you get stuck.
What does Karma do?
Karma is a simple tool that lets you execute JavaScript code in multiple real browsers. Its main purpose, according to the project, is to make test-driven development easy, fast, and fun.
Karma is not a testing framework or an assertion library. It starts a local HTTP server and generates the test runner HTML file that your testing framework normally uses, so the tests run in a browser rather than only in Node.
- Runs tests in real browsers, including desktop and mobile browsers, according to the README's list of use cases.
- Works with frameworks through adapters, including Jasmine, Mocha and QUnit.
- Can be used on your machine during development and on a continuous integration server.
- Can work with Istanbul for coverage reports and RequireJS for source files.
Check the deprecation status before you start
The README states that Karma is deprecated and is no longer accepting new features or general bug fixes. Critical security issues will still be triaged and fixed as necessary.
The README explains that Angular is adding Jest and Web Test Runner support to give Angular projects a migration path off Karma. For projects outside Angular, it names Web Test Runner and jasmine-browser-runner as browser-based direct alternatives, and Jest and Vitest as Node-based alternatives.
- New projects should evaluate the alternatives the README lists before choosing Karma.
- Existing Karma suites can keep running, but the project will not add new features.
Install Karma with a package manager
Karma needs Node.js. The README's install instructions point to the project's installation guide for the full setup, and the repository can be cloned from GitHub.
Use the clone command below to get the source code. For the package-based installation steps, follow the official installation page linked from the README.
- Prerequisite: Node.js.
- Installation method: package manager.
git clone https://github.com/karma-runner/karmaChoose and add a testing framework
Karma needs a framework adapter, because it only runs the tests and serves the runner page. The README lists Jasmine, Mocha and QUnit adapters and notes that many others exist on npm under the karma-adapter keyword.
If your favourite framework has no adapter, the README says you can write your own, and that the maintainers are willing to help.
- Jasmine: karma-jasmine
- Mocha: karma-mocha
- QUnit: karma-qunit
Configure and run your tests
Karma is configured through its configuration documentation, which the README links to. Configure which browsers to use and which files to load, then run your tests from the terminal.
Karma is designed to run locally during development, including on every save, and on a continuous integration server.
- Check the browsers page to see which browsers are supported.
- Use the official configuration guide for the exact options.
Troubleshoot common problems
The README sends troubleshooting questions to the project's FAQ. For longer questions, it points to the mailing list, and for quick questions to Gitter. The issue tracker is for bug reports and feature discussions only.
- Start with the FAQ at the Karma documentation site.
- Use the mailing list or Gitter for support questions, not the issue tracker.
What people use it for
- Running a JavaScript test suite in several real browsers, including desktop and mobile.
- Running tests on every save during local development.
- Running the same browser tests on a continuous integration server.
- Generating coverage reports with Istanbul in a project that already uses it.
- Maintaining an existing Angular project that has not yet moved off Karma.
Frequently asked questions
Is Karma free to use?
Yes. The repository is licensed under the MIT License, and the README links to the LICENSE file. The README says you do not need to sign anything to use it.
What are the requirements for Karma?
The README lists Node.js as the prerequisite. You also need a testing framework adapter, such as Jasmine, Mocha or QUnit, because Karma is only the runner.
Is Karma deprecated?
Yes. The README states that Karma is deprecated and no longer accepting new features or general bug fixes. Only critical security issues will still be fixed.
What are the alternatives to Karma?
The README names Web Test Runner and jasmine-browser-runner as browser-based alternatives, and Jest and Vitest as Node-based alternatives. Angular is adding Jest and Web Test Runner support as a migration path.
Can Karma run tests in real browsers?
Yes. Karma runs JavaScript tests in real browsers, and the README says all the major browsers are supported. See the browsers page for details.
Does Karma include a testing framework?
No. The README says Karma is not a testing framework or an assertion library. It launches an HTTP server and generates the test runner HTML, so you add a framework such as Jasmine, Mocha or QUnit.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Karma suits teams that already have Karma test suites and need to keep them running, or Angular projects that have not yet migrated. New projects should pick one of the alternatives named in the README, such as Web Test Runner, jasmine-browser-runner, Jest or Vitest, because Karma is deprecated and no longer receives feature work.
Install options & downloads