Registry / testing / karma-qunit

karma-qunit

JSON →
library4.2.1jsnpmunverified

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.

npm install karma-qunit
INSTALL
IMPORT
SIG · KARMA-QUNIT
K
karma-qunit
testingjavascriptv4.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

frameworks
frameworks: ['qunit']
frameworks: ['karma-qunit']
The 'qunit' string is used in the `frameworks` array in `karma.conf.js` to enable the plugin.
plugins
plugins: ['karma-qunit']
plugins: [require('karma-qunit')]
The string identifier 'karma-qunit' is used directly in the `plugins` array for Karma to load the plugin.
client.qunit options
client: { qunit: { showUI: true } }
qunit: { showUI: true }
QUnit configuration options are passed via the `client` object in `karma.conf.js` under the `qunit` key, not directly at the root.

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.

const path = require('path'); module.exports = function (config) { config.set({ basePath: '', frameworks: ['qunit'], plugins: ['karma-qunit'], files: [ // Your QUnit test files 'test/**/*.js', // Optional: QUnit library itself if not globally available, though karma-qunit often handles it // path.resolve(__dirname, 'node_modules/qunit/qunit/qunit.js') ], exclude: [], preprocessors: {}, reporters: ['progress'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun: false, concurrency: Infinity, client: { clearContext: false, // Recommended for showUI: true qunit: { showUI: true, testTimeout: 5000, // Example QUnit config option filter: 'my-module:*' // Another example } } }) }
Debug
Known issues
gotchaWhen 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.
fix
Ensure your `karma.conf.js` includes `client: { clearContext: false, qunit: { showUI: true } }`.
affects: >=3.0.0
breakingMajor 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.
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.
affects: >=4.0.0
gotchaThe `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.
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']`.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'karma-qunit'
The `karma-qunit` package was not installed or is not correctly resolved by Node.js/Karma.
fix
Run `npm install --save-dev karma-qunit` to install the package.
TypeError: Cannot read properties of undefined (reading 'qunit') OR Unknown plugin: 'karma-qunit'
The `karma-qunit` plugin is not correctly listed in the `plugins` array of `karma.conf.js`.
fix
Add `plugins: ['karma-qunit']` to your `karma.conf.js`.
Error: Unknown framework: 'qunit'
The `qunit` framework is not correctly listed in the `frameworks` array of `karma.conf.js`.
fix
Add `frameworks: ['qunit']` to your `karma.conf.js`.
Upgrade
Version history
4.2.1latest on npm
Audit
Dependencies
karmarequiredRequired peer dependency for the test runner functionality.
qunitrequiredRequired peer dependency as this package is an adapter for QUnit.
Agent activity
2 hits · last 30 days
node
2
Resources
karma-qunit — npm install karma-qunit · libregistry