Karma Jasmine Adapter

5.1.0 · active · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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`.

const path = require('path');

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    files: [
      // Assuming your test files are in a 'spec' directory
      path.resolve(__dirname, 'src/**/*.js'),
      path.resolve(__dirname, 'spec/**/*.spec.js')
    ],
    browsers: ['ChromeHeadless'],
    reporters: ['progress'],
    autoWatch: true,
    singleRun: false,
    client: {
      jasmine: {
        random: true,
        seed: '12345',
        oneFailurePerSpec: false,
        failFast: false,
        timeoutInterval: 5000
      },
      // Example of custom spec filter, though typically done via `karma run -- --grep` or `jasmine.getEnv().configure`
      // args: ['--grep', 'spec that succeeds']
    }
  });
};

view raw JSON →