Jasmine CLI

6.2.0 · active · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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

view raw JSON →