{"id":11201,"library":"karma-qunit","title":"Karma QUnit Adapter","description":"karma-qunit is a plugin for the Karma test runner that provides an adapter for integrating QUnit, a popular JavaScript unit testing framework. This package allows developers to run their QUnit tests within the Karma environment, facilitating automated testing across various browsers and environments. The current stable version is 4.2.1. Releases appear to be driven by bug fixes and compatibility updates with new Karma or QUnit versions, rather than a fixed cadence, often with several minor releases and occasional major updates. Key differentiators include its tight integration with Karma's robust browser launching and reporting capabilities, offering a more flexible and powerful testing setup compared to running QUnit tests directly in a browser without a test runner. It handles the setup and teardown required for QUnit tests within Karma's lifecycle. While many modern projects lean towards frameworks like Jest or Vitest, karma-qunit remains relevant for projects using QUnit, particularly those with existing Karma test setups or legacy codebases.","status":"active","version":"4.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/karma-runner/karma-qunit","tags":["javascript","karma","karma-plugin","karma-adapter","qunit"],"install":[{"cmd":"npm install karma-qunit","lang":"bash","label":"npm"},{"cmd":"yarn add karma-qunit","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-qunit","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for the test runner functionality.","package":"karma","optional":false},{"reason":"Required peer dependency as this package is an adapter for QUnit.","package":"qunit","optional":false}],"imports":[{"note":"The 'qunit' string is used in the `frameworks` array in `karma.conf.js` to enable the plugin.","wrong":"frameworks: ['karma-qunit']","symbol":"frameworks","correct":"frameworks: ['qunit']"},{"note":"The string identifier 'karma-qunit' is used directly in the `plugins` array for Karma to load the plugin.","wrong":"plugins: [require('karma-qunit')]","symbol":"plugins","correct":"plugins: ['karma-qunit']"},{"note":"QUnit configuration options are passed via the `client` object in `karma.conf.js` under the `qunit` key, not directly at the root.","wrong":"qunit: { showUI: true }","symbol":"client.qunit options","correct":"client: { qunit: { showUI: true } }"}],"quickstart":{"code":"const path = require('path');\n\nmodule.exports = function (config) {\n  config.set({\n    basePath: '',\n    frameworks: ['qunit'],\n    plugins: ['karma-qunit'],\n    files: [\n      // Your QUnit test files\n      'test/**/*.js',\n      // Optional: QUnit library itself if not globally available, though karma-qunit often handles it\n      // path.resolve(__dirname, 'node_modules/qunit/qunit/qunit.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: ['Chrome'],\n    singleRun: false,\n    concurrency: Infinity,\n    client: {\n      clearContext: false, // Recommended for showUI: true\n      qunit: {\n        showUI: true,\n        testTimeout: 5000, // Example QUnit config option\n        filter: 'my-module:*' // Another example\n      }\n    }\n  })\n}","lang":"javascript","description":"This quickstart demonstrates a basic Karma configuration (`karma.conf.js`) for running QUnit tests, including how to enable the `karma-qunit` plugin, specify test files, and pass custom QUnit configuration options via the `client` property. It also includes the crucial `clearContext: false` for proper UI display."},"warnings":[{"fix":"Ensure your `karma.conf.js` includes `client: { clearContext: false, qunit: { showUI: true } }`.","message":"When enabling `showUI: true` for QUnit, the `clearContext: false` option in the Karma client configuration must also be set. Failing to do so will prevent the QUnit UI from displaying correctly in non-debug mode within the browser.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Consult the `karma-qunit` GitHub release notes or changelog for specific migration steps when upgrading across major versions. Update `karma` and `qunit` peer dependencies to compatible versions as specified.","message":"Major versions of `karma-qunit` may introduce breaking changes related to compatibility with new `karma` or `qunit` versions. Always check the release notes when upgrading peer dependencies or `karma-qunit` itself.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure `karma-qunit` is installed as a dev dependency (`npm install --save-dev karma-qunit`) and configured in `karma.conf.js` using `frameworks: ['qunit']` and `plugins: ['karma-qunit']`.","message":"The `karma-qunit` package is primarily a Karma plugin, not a direct JavaScript library for import. You configure it within your `karma.conf.js` file rather than importing symbols into your test files or application code.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev karma-qunit` to install the package.","cause":"The `karma-qunit` package was not installed or is not correctly resolved by Node.js/Karma.","error":"Error: Cannot find module 'karma-qunit'"},{"fix":"Add `plugins: ['karma-qunit']` to your `karma.conf.js`.","cause":"The `karma-qunit` plugin is not correctly listed in the `plugins` array of `karma.conf.js`.","error":"TypeError: Cannot read properties of undefined (reading 'qunit') OR Unknown plugin: 'karma-qunit'"},{"fix":"Add `frameworks: ['qunit']` to your `karma.conf.js`.","cause":"The `qunit` framework is not correctly listed in the `frameworks` array of `karma.conf.js`.","error":"Error: Unknown framework: 'qunit'"}],"ecosystem":"npm"}