karma-jasmine is a Karma plugin that serves as an adapter for the Jasmine testing framework, enabling developers to run their Jasmine-based unit tests within the Karma test runner environment. The current stable version is 5.1.0, released in June 2022, with a consistent release cadence addressing bug fixes, dependency updates (including `jasmine-core`), and minor feature enhancements. It primarily functions by providing the `jasmine` framework to Karma's configuration, allowing seamless integration and execution of Jasmine specs. Key differentiators include its tight coupling with the Karma ecosystem, offering features like custom spec filtering, debug-by-URL capabilities for focused testing, and basic sharding support. This package is essential for projects using Karma for test automation and Jasmine for writing their tests, abstracting away the complexities of setting up the two together.
npm install karma-jasmineVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure Karma to use karma-jasmine, specifying test files, browsers, and passing Jasmine-specific options directly via the `client.jasmine` property in `karma.conf.js`.
Upgrade Node.js to version 12 or newer. Use `nvm install 16 && nvm use 16` (or desired version) or update `package.json` engines and re-install dependencies.
Ensure your project's `karma` dependency is updated to `^6.0.0` (e.g., `npm install karma@^6.0.0 --save-dev`).
Upgrade Node.js to version 10 or newer (ideally 14+ for v4.0.0) if you intend to use `karma-jasmine` v4.
Verify that your `files` array accurately points to all necessary source code and test spec files. Use glob patterns carefully and consider `included: false` for files that should only be served, not executed globally.
Install Karma: `npm install karma --save-dev`
Ensure `karma.conf.js` exports a function: `module.exports = function(config) { /* ... */ }`.Review the `files` array in `karma.conf.js` and ensure the glob patterns or file paths accurately include your Jasmine test files (e.g., `['spec/**/*.js']`).
Ensure your Jasmine spec files are correctly loaded by Karma-Jasmine and that you are writing test code within `describe` blocks. This error can also occur if `frameworks: ['jasmine']` is missing from `karma.conf.js`.