# karma-jasmine

> A Karma plugin - adapter for Jasmine testing framework.

Latest version **5.1.0** (published 2022-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install karma-jasmine
pnpm add karma-jasmine
yarn add karma-jasmine
bun add karma-jasmine
```

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2022-06-16 |
| First published | 2013-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/karma-jasmine) |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 25.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 537 |
| Author | Vojta Jina |
| Maintainers | dignifiedquire, zzo, maksimr, vojtajina, karmarunnerbot |
| Keywords | karma-plugin, karma-adapter, jasmine |

## Links

- npm: https://www.npmjs.com/package/karma-jasmine
- Repository: https://github.com/karma-runner/karma-jasmine
- Homepage: https://github.com/karma-runner/karma-jasmine#readme
- Issues: https://github.com/karma-runner/karma-jasmine/issues
- npm.io page: https://npm.io/package/karma-jasmine

## Dependencies (1)

- [jasmine-core](https://npm.io/package/jasmine-core.md) ^4.1.0

## Recent versions

- 5.1.0 (latest) — 2022-06-16
- 0.2.2 (2_0) — 2014-03-13
- 5.0.1 — 2022-05-13
- 5.0.0 — 2022-04-12
- 4.0.2 — 2022-03-30
- 4.0.1 — 2020-08-12
- 4.0.0 — 2020-08-11
- 3.3.1 — 2020-05-28
- 3.3.0 — 2020-05-28
- 3.2.0 — 2020-05-26
- 3.1.1 — 2020-02-11
- 3.1.0 — 2020-01-10
- 3.0.3 — 2020-01-08
- 3.0.1 — 2020-01-06
- 3.0.0 — 2020-01-04
- … 29 more at https://npm.io/package/karma-jasmine/versions

## README

# karma-jasmine

[![npm version](https://img.shields.io/npm/v/karma-jasmine?style=flat-square)](https://www.npmjs.com/package/karma-jasmine)
[![npm downloads](https://img.shields.io/npm/dm/karma-jasmine?style=flat-square)](https://www.npmjs.com/package/karma-jasmine)
[![Release Workflow Status](https://img.shields.io/github/workflow/status/karma-runner/karma-jasmine/Release/master?style=flat-square&logo=github&label=Release)](https://github.com/karma-runner/karma-jasmine/actions/workflows/release.yml?query=branch%3Amaster)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen?style=flat-square)](https://github.com/karma-runner/karma-jasmine)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079?style=flat-square)](https://github.com/semantic-release/semantic-release)

> Adapter for the [Jasmine](https://jasmine.github.io/) testing framework.

## Installation

```bash
npm install karma-jasmine --save-dev
```

## Configuration

```js
// 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

```bash
$ 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`:

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

```js
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](https://jasmine.github.io/api/edge/Configuration#specFilter) is also supported.

Example:

```js
// 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](https://karma-runner.github.io/).

---
_Source: https://npm.io/package/karma-jasmine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
