{"id":11199,"library":"karma-jasmine","title":"Karma Jasmine Adapter","description":"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.","status":"active","version":"5.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/karma-runner/karma-jasmine","tags":["javascript","karma-plugin","karma-adapter","jasmine"],"install":[{"cmd":"npm install karma-jasmine","lang":"bash","label":"npm"},{"cmd":"yarn add karma-jasmine","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-jasmine","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, karma-jasmine is an adapter plugin for Karma.","package":"karma","optional":false}],"imports":[{"note":"karma-jasmine is a Karma plugin configured in `karma.conf.js`, not directly imported into application or test code via `import` or `require`.","wrong":"import 'karma-jasmine';","symbol":"frameworks","correct":"config.set({ frameworks: ['jasmine'] })"},{"note":"Jasmine configuration options are passed via `config.client.jasmine` in `karma.conf.js`.","symbol":"client.jasmine","correct":"config.set({ client: { jasmine: { random: true } } })"},{"note":"While `--grep` works directly with `karma run`, embedding it in `client.args` ensures it's applied consistently across runs configured in `karma.conf.js`.","wrong":"karma start --grep=<pattern>","symbol":"client.args (grep)","correct":"config.set({ client: { args: ['--grep', '<pattern>'] } })"}],"quickstart":{"code":"const path = require('path');\n\nmodule.exports = function(config) {\n  config.set({\n    frameworks: ['jasmine'],\n    files: [\n      // Assuming your test files are in a 'spec' directory\n      path.resolve(__dirname, 'src/**/*.js'),\n      path.resolve(__dirname, 'spec/**/*.spec.js')\n    ],\n    browsers: ['ChromeHeadless'],\n    reporters: ['progress'],\n    autoWatch: true,\n    singleRun: false,\n    client: {\n      jasmine: {\n        random: true,\n        seed: '12345',\n        oneFailurePerSpec: false,\n        failFast: false,\n        timeoutInterval: 5000\n      },\n      // Example of custom spec filter, though typically done via `karma run -- --grep` or `jasmine.getEnv().configure`\n      // args: ['--grep', 'spec that succeeds']\n    }\n  });\n};","lang":"javascript","description":"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`."},"warnings":[{"fix":"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.","message":"Version 5.0.0 of karma-jasmine dropped support for Node.js 10. Projects using Node.js 10 or older will need to upgrade their Node.js environment to version 12 or higher to use karma-jasmine v5.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure your project's `karma` dependency is updated to `^6.0.0` (e.g., `npm install karma@^6.0.0 --save-dev`).","message":"With the release of v5.0.0, the `karma` peer dependency was strictly limited to `^6.0.0`. Older versions of Karma are no longer supported by `karma-jasmine` v5.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade Node.js to version 10 or newer (ideally 14+ for v4.0.0) if you intend to use `karma-jasmine` v4.","message":"Version 4.0.0 dropped support for Node.js 8. Projects still on Node.js 8 will encounter issues. This version also added support for Node.js 14.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"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.","message":"Incorrectly configuring `files` array in `karma.conf.js` can lead to tests not being found or unexpected execution order. Ensure test files and any required source files are correctly included.","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":"Install Karma: `npm install karma --save-dev`","cause":"Karma is a peer dependency and must be installed separately.","error":"Error: Cannot find module 'karma' from '<path>'"},{"fix":"Ensure `karma.conf.js` exports a function: `module.exports = function(config) { /* ... */ }`.","cause":"Attempting to use `require('karma')` directly to configure Karma instead of exporting a function that receives the config object.","error":"TypeError: config.set is not a function"},{"fix":"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']`).","cause":"The `files` array in `karma.conf.js` does not correctly point to any Jasmine spec files.","error":"No specs found"},{"fix":"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`.","cause":"Jasmine environment functions (e.g., `describe`, `it`, `expect`) are globally available in spec files but not necessarily in auxiliary scripts or outside the test execution context.","error":"Jasmine is not defined"}],"ecosystem":"npm"}