Registry / testing / jasmine

jasmine

JSON →
library3.99.0jsnpmunverified

The `jasmine` package provides a command-line interface (CLI) and supporting utilities for running Jasmine Behavior Driven Development (BDD) tests in Node.js environments. As of its current stable version 6.2.0, this package acts as a runner for `jasmine-core`, which is the actual testing framework. Jasmine is known for its clean and easy-to-understand syntax, requiring no DOM or external JavaScript frameworks, making it suitable for a wide range of JavaScript projects. The project maintains an active release cadence, with minor and patch updates frequently, and major versions introducing significant changes every few months. It is compatible with both ES modules and CommonJS modules and officially supports Node.js versions 20, 22, and 24, with best-effort support for environments past their end-of-life.

npm install jasmine
INSTALL
IMPORT
SIG · JASMINE
J
jasmine
testingjavascriptv3.99.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Jasmine
import Jasmine from 'jasmine';
const Jasmine = require('jasmine'); // For CommonJS in ESM context without appropriate config
The `Jasmine` class is used for programmatic configuration and execution of tests. Both ESM and CommonJS `require()` are supported for this import.
describe, it, expect
/* No explicit import needed in spec files */
These are global functions provided by the Jasmine test runner and are available in test files without explicit imports. For TypeScript, install `@types/jasmine` for global type definitions.
Config
import type { Config } from 'jasmine';
Use type imports for the configuration object schema when working with TypeScript. The `jasmine.json` file dictates runtime configuration.

Demonstrates setting up Jasmine, writing a basic spec, and running tests via the CLI.

/* src/greeter.ts */ export function greet(name: string): string { return `Hello, ${name}!`; } /* spec/greeter.spec.ts */ import { greet } from '../src/greeter'; describe('Greeter', () => { it('should return a greeting with the given name', () => { expect(greet('World')).toEqual('Hello, World!'); }); it('should handle empty names gracefully', () => { expect(greet('')).toEqual('Hello, !'); }); it('should support custom matchers if configured', () => { // This test assumes a custom matcher 'toBeGreeting' is set up // expect('Hello, Jasmine!').toBeGreeting(); expect(greet('Tester')).toContain('Tester'); }); }); /* Terminal commands */ // 1. Install Jasmine npm install --save-dev jasmine // 2. Initialize Jasmine project (creates spec/support/jasmine.json) npx jasmine init // 3. Run tests npx jasmine
jasmine --version
Debug
Known issues
breakingJasmine v6.0.0 dropped support for Node.js versions older than 20. Projects running on Node.js 18 or earlier will encounter issues.
fix
Upgrade your Node.js environment to version 20, 22, or 24.
affects: >=6.0.0
breakingThe `ConsoleReporter` was moved from the `jasmine` package to `@jasminejs/reporters` in v6.0.0. Direct imports or references to `ConsoleReporter` from `jasmine` will break.
fix
If using `ConsoleReporter` programmatically, install `@jasminejs/reporters` and update your imports accordingly. For example, `import { ConsoleReporter } from '@jasminejs/reporters';`
affects: >=6.0.0
breakingWith Jasmine v6.0.0, if multiple configuration files are present, only the first one is loaded. This changes previous behavior where multiple configs might have been merged.
fix
Consolidate your Jasmine configuration into a single `jasmine.json` file or use programmatic configuration via the `Jasmine` class to manage multiple configurations explicitly.
affects: >=6.0.0
breakingJasmine-core v6.0.0 removed private APIs from its global namespace. Relying on undocumented or internal APIs will cause breakage, as these were never guaranteed to be stable.
fix
Refactor code to use documented public APIs. Avoid relying on internal Jasmine structures that were not explicitly exposed for public consumption.
affects: >=6.0.0
deprecatedJasmine v6.x emits deprecation warnings when used with `karma-jasmine` and other legacy Angular tools. Jasmine v7.0 will drop compatibility with these tools entirely.
fix
For Karma users outside Angular, consider migrating to alternatives like `jasmine-browser-runner` or `web-test-runner`. Angular users should consult Angular documentation for future Jasmine support.
affects: >=6.0.0
gotchaJasmine only officially supports specific Node.js versions (20, 22, 24). Environments past end-of-life or odd-numbered Node versions are supported on a best-effort basis and may be dropped in future minor releases if support becomes impractical.
fix
Ensure your project uses a currently supported Node.js Long Term Support (LTS) release for reliable operation and continued compatibility.
affects: >=5.0.0
Errors
Common errors & fixes
ReferenceError: describe is not defined
This error occurs when a test file using Jasmine's global functions (`describe`, `it`, `expect`) is run directly with `node` instead of through the `jasmine` CLI or a configured test runner.
fix
Run your tests using `npx jasmine` (or `npm test` if configured) instead of `node your-spec-file.js`. Ensure Jasmine is correctly installed and initialized (`npx jasmine init`).
TS2304: Cannot find name 'describe'
When using TypeScript, the global types for Jasmine's testing functions (`describe`, `it`, `expect`) are missing.
fix
Install the Jasmine type definitions: `npm install --save-dev @types/jasmine`. Ensure your `tsconfig.json` includes `jasmine` in the `types` array or that `typeRoots` is correctly configured to find `@types` packages.
Upgrade
Version history
3.99.0latest on npm
Audit
Dependencies
jasmine-corerequiredThis package is a CLI wrapper for the core Jasmine testing framework.
Agent activity
6 hits · last 30 days
node
6
Resources
jasmine — npm install jasmine · libregistry