{"id":11205,"library":"karma","title":"Karma Test Runner","description":"Karma, currently at stable version 6.4.4, is a long-standing JavaScript test runner specifically designed to execute tests directly within real browser environments. Its core utility lies in facilitating test-driven development by providing quick feedback cycles, enabling testing across diverse browsers (desktop, mobile, tablets) and integration with continuous integration servers. It supports running tests on file saves and offers features like coverage reporting via Istanbul. However, the project has been officially deprecated. The web testing ecosystem has evolved significantly since Karma's inception over ten years ago, leading to the emergence of more performant and modern alternatives. While critical security issues will continue to be addressed until 12 months after Angular CLI's Web Test Runner support stabilizes, no new features or general bug fixes are being accepted. Users are strongly encouraged to migrate to modern alternatives such as Web Test Runner, `jasmine-browser-runner`, Jest, or Vitest.","status":"deprecated","version":"6.4.4","language":"javascript","source_language":"en","source_url":"git://github.com/karma-runner/karma","tags":["javascript","karma","spectacular","runner","js","testing","test"],"install":[{"cmd":"npm install karma","lang":"bash","label":"npm"},{"cmd":"yarn add karma","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"For programmatic control of the Karma server. Karma is a CommonJS module, so `require()` is the standard way to import its components in Node.js.","wrong":"import { Server } from 'karma';","symbol":"Server","correct":"const Server = require('karma').Server;"},{"note":"For resolving Karma configuration files programmatically within a Node.js environment.","wrong":"import { config } from 'karma';","symbol":"config","correct":"const config = require('karma').config;"},{"note":"Provides methods like `runner.run()` to programmatically start a test run against an already running Karma server.","wrong":"import { runner } from 'karma';","symbol":"runner","correct":"const runner = require('karma').runner;"}],"quickstart":{"code":"// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['jasmine'],\n    files: [\n      'src/**/*.js',\n      'test/**/*.js'\n    ],\n    exclude: [],\n    preprocessors: {},\n    reporters: ['progress'],\n    port: 9876,\n    colors: true,\n    logLevel: config.LOG_INFO,\n    autoWatch: true,\n    browsers: ['ChromeHeadless'], // Ensure karma-chrome-launcher is installed\n    singleRun: false,\n    concurrency: Infinity\n  });\n};\n\n// test/example.test.js\ndescribe('A simple test', function() {\n  it('should pass', function() {\n    expect(true).toBe(true);\n  });\n});","lang":"javascript","description":"This quickstart sets up a basic `karma.conf.js` using Jasmine and ChromeHeadless. To run, first install `karma`, `karma-jasmine`, `jasmine-core`, and `karma-chrome-launcher` (`npm install -D karma karma-jasmine jasmine-core karma-chrome-launcher`), then execute `npx karma start`."},"warnings":[{"fix":"Migrate your testing setup to current alternatives like Web Test Runner, Jest, Vitest, or `jasmine-browser-runner`. Refer to the Karma README and Angular blog for migration guides.","message":"Karma is officially deprecated. The project will no longer receive new features or general bug fixes. While critical security fixes will continue for a limited period, users are strongly encouraged to migrate to modern alternatives.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Ensure your Node.js environment meets the `engines` requirement. It is recommended to use an actively maintained LTS version of Node.js for stability.","message":"Karma requires Node.js version >= 10. Using older Node.js versions will lead to installation and runtime failures. Using very new, unsupported Node.js versions might also lead to compatibility issues, particularly with older plugins.","severity":"gotcha","affected_versions":"<10"},{"fix":"Upgrade Karma to version `6.3.17` or higher, which includes an update to a maintained version of the `colors` package, mitigating this security risk.","message":"A malicious update to the `colors` package (a dependency of `karma`) in January 2022 introduced potential supply chain vulnerabilities, leading to corrupted output or system issues for users who pulled specific versions.","severity":"breaking","affected_versions":"=6.3.16"},{"fix":"Upgrade Karma to version `6.3.16` or higher to receive the fix for this security vulnerability.","message":"An 'Open Redirect Vulnerability' was present in Karma, which could allow an attacker to redirect users to arbitrary external URLs if certain conditions were met.","severity":"breaking","affected_versions":"<6.3.16"},{"fix":"Always use CommonJS `require()` and `module.exports` syntax in `karma.conf.js`. If you need to integrate ESM modules, consider transpiling your configuration or using a wrapper script.","message":"Karma's configuration file (`karma.conf.js`) is fundamentally designed for CommonJS syntax (`module.exports = function(config) { ... }`). Attempting to use ESM `import`/`export` syntax directly in this file will lead to syntax errors or unexpected behavior, even in Node.js environments configured for ESM.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify that you have the necessary browser launcher installed (e.g., `karma-chrome-launcher`), that it's listed in the `browsers` array of your `karma.conf.js`, and that no firewall or system setting is preventing the browser from launching or connecting to the Karma server.","cause":"The Karma server started successfully, but no browser instance connected to it. This can happen if a browser launcher is missing, misconfigured, or if the browser failed to launch.","error":"No captured browser, open http://localhost:9876/"},{"fix":"Install the corresponding Karma browser launcher package (e.g., `npm install --save-dev karma-chrome-launcher`) and ensure it's listed in your `karma.conf.js` file, typically in the `plugins` array if manually specified, or implicitly used if added to `browsers`.","cause":"Karma cannot find the necessary plugin to launch the specified browser (e.g., 'Chrome', 'Firefox', 'Safari').","error":"Can not load \"Chrome\" browser! Are you missing a plugin for it?"},{"fix":"Install the correct Karma plugin for your chosen framework (e.g., `npm install --save-dev karma-jasmine`) and ensure it's included in the `frameworks` array within your `karma.conf.js`.","cause":"The testing framework specified in your `karma.conf.js` (e.g., 'jasmine', 'mocha', 'qunit') does not have a corresponding Karma plugin installed.","error":"Can not load \"jasmine\" framework! Are you missing a plugin for it?"}],"ecosystem":"npm"}