Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

karma-jasmine

karma-runner7mMIT5.1.0TypeScript support: definitely-typed

A Karma plugin - adapter for Jasmine testing framework.

karma-plugin, karma-adapter, jasmine

readme

karma-jasmine

npm version npm downloads Release Workflow Status js-standard-style semantic-release

Adapter for the Jasmine testing framework.

Installation

npm install karma-jasmine --save-dev

Configuration

// karma.conf.js
module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    files: [
      '*.js'
    ]
  })
}

If you want to run only some tests whose name match a given pattern you can do this in the following way

$ karma start &
$ karma run -- --grep=<pattern>

where pattern is either a string (e.g --grep=#slow runs tests containing "#slow") or a Regex (e.g --grep=/^(?!.*#slow).*$/ runs tests not containing "#slow").

You can also pass it to karma.config.js:

module.exports = function(config) {
  config.set({
    // ...
    client: {
      args: ['--grep', '<pattern>'],
      // ...
    }
  })
}

If you want to pass configuration options directly to jasmine you can do this in the following way

module.exports = function(config) {
  config.set({
    client: {
      jasmine: {
        random: true,
        seed: '4321',
        oneFailurePerSpec: true,
        failFast: true,
        timeoutInterval: 1000
      }
    }
  })
}

Debug by URL

Failing tests print a debug URL with ?spec=. Use it with --no_single_run and paste it into your browser to focus on a single failing test.

Sharding

By setting config.client.shardIndex and config.client.totalShards, you can run a subset of the full set of specs. Complete sharding support needs to be done in the process that calls karma, and would need to support test result integration across shards.

Custom spec filter

Providing a custom spec filter is also supported.

Example:

// Users are able to set a custom specFilter themselves

jasmine.getEnv().configure({
  specFilter: function (spec) {
    return spec.getFullName() === 'spec that succeeds'
  }
})

describe('spec', () => {
  it('that fails', () => {
    fail('This spec should not run!')
  })

  it('that succeeds', () => {
    expect(1).toBe(1)
  })
})

For more information on Karma see the homepage.

changelog

5.1.0 (2022-06-16)

Features

  • spec-filter: allow custom specFilter (b73dbd6)

5.0.1 (2022-05-13)

Bug Fixes

  • fixes matches performance issue, github#302 (e964fa6)

5.0.0 (2022-04-12)

Bug Fixes

  • limit karma peer dependency to ^6.0.0 (d72c124)

Build System

  • drop Node.js 10 support (ea691e8)

Features

  • deps: update dependencies including jasmine-core (821f094)

BREAKING CHANGES

  • The minimum required version of karma is 6.0.0.
  • The minimum required version of Node is 12.0.0.
  • deps: jasmine-core was updated to the 4.1.0.

Please refer to the release notes for the complete list of changes and migration instructions.

4.0.2 (2022-03-30)

Bug Fixes

  • sync package-lock.json and package.json (4dacc5d)

4.0.1 (2020-08-12)

Bug Fixes

  • adapter: filter functions from result.order (#272) (28f337c)

4.0.0 (2020-08-11)

chore

BREAKING CHANGES

  • Drop support for node 8 (add support for node 14)

3.3.1 (2020-05-28)

Bug Fixes

3.3.0 (2020-05-28)

Features

  • reporter: emit info events for suiteStarted/suiteDone (#269) (7b73ce0)

3.2.0 (2020-05-26)

Features

  • results: forward passedExpectations and properties (#268) (ad1d7dd)

3.1.1 (2020-02-11)

Bug Fixes

  • adapter: do not emit debug url unless in a browser (#263) (9bcce88), closes #262

3.1.0 (2020-01-10)

Features

  • adapter: support spec=name URL and sharding (#243) (39b1582)

3.0.3 (2020-01-08)

Bug Fixes

3.0.2 (2020-01-08)

3.0.1 (2020-01-06)

Bug Fixes

Chores

Features

  • adapter: log when Jasmine fails because no expect() were run (#238) (646796e)
  • reporter: On no-single-run and failure, emit a debug URL (#235) (76f092a)
  • Propagate errors thrown in afterAll blocks (f3fa264), closes #161
  • update the version to 2.0.0 and restrict node version available to 4.0 (c84316e)
  • Update deps and drop node v6 to match karma v4.0 (#233) (097eed4), closes #233
  • feat (adapter): Use jasmine's new configure method (#224) (6663e47), closes #224 #221

BREAKING CHANGES

  • drop support for node v6

  • Also update travis config to drop v6 andd v10

  • stopOnFailure, which was previously documented in karma-jasmine's README, is not configuration option for jasmine. Use oneFailurePerSpec instead.

Requires peerDependency Jasmine@^3.3.0

  • deps: Drop support for node 4.x

3.0.0 (2020-01-04)

  • Update deps and drop node v6 to match karma v4.0 (#233) (097eed4), closes #233

Bug Fixes

  • build: run eslint on npm test (#237) (a12024d)
  • stack: On error in beforeAll/afterAll relevant information to debug are miss… (#232) (cd6f060)
  • travis: use new syntax for xenial and pin to it. (#236) (cb99ef8)

Features

  • adapter: log when Jasmine fails because no expect() were run (#238) (646796e)
  • reporter: On no-single-run and failure, emit a debug URL (#235) (76f092a)

BREAKING CHANGES

  • drop support for node v6

  • Also update travis config to drop v6 andd v10

2.0.1 (2018-11-17)

Bug Fixes

  • dep: Depend upon the jasmine-core version we test (#229) (c4dfef5)

2.0.0 (2018-11-15)

  • feat (adapter): Use jasmine's new configure method (#224) (6663e47), closes #224 #221

Bug Fixes

Chores

Features

  • Propagate errors thrown in afterAll blocks (f3fa264), closes #161
  • update the version to 2.0.0 and restrict node version available to 4.0 (c84316e)

BREAKING CHANGES

  • stopOnFailure, which was previously documented in karma-jasmine's README, is not configuration option for jasmine. Use oneFailurePerSpec instead.

Requires peerDependency Jasmine@^3.3.0

  • deps: Drop support for node 4.x

1.1.2 (2018-05-02)

Bug Fixes

  • adapter: Remove incorrect function and its call. (#183) (cada4a9)
  • time: report correct time since Jasmine v2.9.0 (#197) (022ee04), closes #196

Features

  • Propagate errors thrown in afterAll blocks (f3fa264), closes #161
  • update the version to 2.0.0 and restrict node version available to 4.0 (c84316e)

1.1.1 (2017-12-01)

Features

  • Propagate errors thrown in afterAll blocks (f3fa264), closes #161

1.1.0 (2016-12-09)

Bug Fixes

Features

1.0.2 (2016-05-04)

Bug Fixes

  • version: argh, make 'build' a prereq for test and fix gruntfile for eslint(f2a6109)

1.0.1 (2016-05-04)

Bug Fixes

  • grunt: load 'build' grunt task and make a pre-req for releasing(1861ae0)

1.0.0 (2016-05-03)

0.3.8 (2016-03-16)

Bug Fixes

  • v0.3.7 does not work in ie8 fix #105 (d44b489), closes #105

Features

  • adapter: add executedExpectationsCount to result (666c207)