or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdconfiguration.mdindex.mdparallel-runner.mdreporting.mdsequential-runner.md
tile.json

tessl/npm-jasmine

CLI for Jasmine, a simple JavaScript testing framework for browsers and Node

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/jasmine@5.10.x

To install, run

npx @tessl/cli install tessl/npm-jasmine@5.10.0

index.mddocs/

Jasmine

Jasmine is a Node.js CLI and supporting code for running Jasmine specs under Node. It provides both sequential and parallel test execution capabilities, with extensive configuration options, filtering, and reporting features. The package acts as a wrapper around jasmine-core, providing Node.js-specific functionality including file loading, configuration management, and process orchestration.

Package Information

  • Package Name: jasmine
  • Package Type: npm
  • Language: JavaScript (Node.js)
  • Installation: npm install --save-dev jasmine

Core Imports

const Jasmine = require('jasmine');
const ParallelRunner = require('jasmine/parallel');
const { ConsoleReporter } = require('jasmine');

For ES modules:

import Jasmine from 'jasmine';
import ParallelRunner from 'jasmine/parallel';

Basic Usage

const Jasmine = require('jasmine');

const jasmine = new Jasmine();
jasmine.loadConfigFile(); // loads spec/support/jasmine.json by default
jasmine.execute();

For parallel execution:

const ParallelRunner = require('jasmine/parallel');

const runner = new ParallelRunner({ numWorkers: 4 });
runner.loadConfigFile();
runner.execute();

CLI Usage

Initialize a project:

npx jasmine init

Install examples:

npx jasmine examples

Run tests:

npx jasmine
npx jasmine spec/my-spec.js
npx jasmine --parallel=4
npx jasmine --filter="integration"

Architecture

Jasmine is built around several key components:

  • Sequential Runner: Jasmine class providing single-process test execution with full jasmine-core integration
  • Parallel Runner: ParallelRunner class distributing specs across multiple worker processes for faster execution
  • Configuration System: Flexible configuration loading from JSON/JS files with CLI override support
  • Reporting System: Built-in console reporter with support for custom reporters and parallel aggregation
  • CLI Interface: Full-featured command-line tool with sub-commands and extensive options
  • Module Loading: Sophisticated ES module and CommonJS loading with automatic format detection

Capabilities

Sequential Test Execution

Core test runner providing full control over test execution with jasmine-core integration, custom matchers, and flexible configuration.

class Jasmine {
  constructor(options?: JasmineOptions);
  execute(files?: string[], filter?: string | RegExp | FilterObject): Promise<JasmineDoneInfo>;
  enumerate(): Promise<EnumeratedSuiteOrSpec[]>;
  randomizeTests(value: boolean): void;
  seed(value: string): void;
  addReporter(reporter: Reporter): void;
  clearReporters(): void;
  addMatchers(matchers: CustomMatchers): void;
  readonly env: Env;
  exitOnCompletion: boolean;
}

interface JasmineOptions {
  projectBaseDir?: string;
  globals?: boolean;
}

Sequential Runner

Parallel Test Execution

High-performance parallel test execution distributing specs across multiple worker processes with automatic load balancing.

class ParallelRunner {
  constructor(options?: ParallelRunnerOptions);
  execute(files?: string[], filterString?: string): Promise<JasmineDoneInfo>;
  addReporter(reporter: Reporter, errorContext?: string): void;
  clearReporters(): void;
  exitOnCompletion: boolean;
}

interface ParallelRunnerOptions {
  projectBaseDir?: string;
  numWorkers?: number;
  globals?: boolean;
}

Parallel Runner

Configuration Management

Comprehensive configuration system supporting JSON and JavaScript config files with CLI overrides and environment variable support.

interface Configuration {
  spec_dir?: string;
  spec_files?: string[];
  helpers?: string[];
  requires?: string[];
  jsLoader?: 'import' | 'require';
  failSpecWithNoExpectations?: boolean;
  stopSpecOnExpectationFailure?: boolean;
  stopOnSpecFailure?: boolean;
  alwaysListPendingSpecs?: boolean;
  random?: boolean;
  verboseDeprecations?: boolean;
  reporters?: Reporter[];
  globalSetup?: () => void | Promise<void>;
  globalSetupTimeout?: number;
  globalTeardown?: () => void | Promise<void>;
  globalTeardownTimeout?: number;
  env?: EnvConfig;
}

Configuration

Command Line Interface

Full-featured CLI with sub-commands, extensive options, and environment variable support for integrating Jasmine into development workflows.

jasmine [command] [options] [files]

Commands:
  init        Initialize jasmine project
  examples    Install example specs
  help, -h    Show help
  version, -v Show versions
  enumerate   List suites and specs

Options:
  --parallel=N        Run in parallel with N workers
  --no-color/--color  Control color output
  --filter=REGEX      Filter specs by regex
  --filter-path=JSON  Filter specs by path
  --helper=PATTERN    Load helper files
  --require=MODULE    Require modules  
  --fail-fast         Stop on first failure
  --config=PATH       Specify config file
  --reporter=PATH     Use custom reporter
  --verbose           Enable verbose output

Command Line Interface

Reporting System

Built-in console reporter with support for custom reporters, parallel execution aggregation, and detailed failure reporting.

class ConsoleReporter {
  constructor();
  setOptions(options: ConsoleReporterOptions): void;
  jasmineStarted(options: any): void;
  jasmineDone(result: JasmineDoneInfo): void;
  specDone(result: SpecResult): void;
  suiteDone(result: SuiteResult): void;
  reporterCapabilities: { parallel: boolean };
}

interface ConsoleReporterOptions {
  showColors?: boolean;
  print?: (text: string) => void;
  stackFilter?: (stack: string) => string;
  randomSeedReproductionCmd?: (seed: string) => string;
  alwaysListPendingSpecs?: boolean;
}

Reporting

Common Types

interface JasmineDoneInfo {
  overallStatus: 'passed' | 'failed' | 'incomplete';
  totalTime?: number;
  numWorkers?: number;
  failedExpectations: FailedExpectation[];
  deprecationWarnings: DeprecationWarning[];
  incompleteCode?: string;
  incompleteReason?: string;
}

interface EnumeratedSuiteOrSpec {
  type: 'suite' | 'spec';
  description: string;
  children?: EnumeratedSuiteOrSpec[];
}

interface FilterObject {
  path: string[];
}

interface FailedExpectation {
  actual: any;
  expected: any;
  globalErrorType?: string;
  matcherName: string;
  message: string;
  passed: false;
  stack: string;
}

interface DeprecationWarning {
  message: string;
  stack?: string;
}

interface Reporter {
  jasmineStarted?(suiteInfo: JasmineStartedInfo): void;
  jasmineDone?(result: JasmineDoneInfo): void;
  specDone?(result: SpecResult): void;
  suiteDone?(result: SuiteResult): void;
  reporterCapabilities?: { parallel?: boolean };
}

interface JasmineStartedInfo {
  totalSpecsDefined?: number;
  order?: {
    random: boolean;
    seed: string;
  };
  parallel?: boolean;
}

interface SpecResult {
  id: string;
  description: string;
  fullName: string;
  failedExpectations: FailedExpectation[];
  passedExpectations: PassedExpectation[];
  pendingReason?: string;
  status: 'passed' | 'failed' | 'pending' | 'disabled';
  debugLogs?: DebugLogEntry[];
  duration?: number;
}

interface SuiteResult {
  id: string;
  description: string;
  fullName: string;
  failedExpectations: FailedExpectation[];
  status: 'passed' | 'failed' | 'disabled';
}

interface PassedExpectation {
  matcherName: string;
  message: string;
  stack: string;
  passed: true;
}

interface DebugLogEntry {
  timestamp: number;
  message: string;
}

interface CustomMatchers {
  [matcherName: string]: (util?: MatchersUtil, customEqualityTesters?: CustomEqualityTester[]) => {
    compare(actual: any, expected?: any): MatcherResult;
    negativeCompare?(actual: any, expected?: any): MatcherResult;
  };
}

interface MatcherResult {
  pass: boolean;
  message?: string | (() => string);
}

interface MatchersUtil {
  equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean;
  contains(haystack: any, needle: any, customTesters?: CustomEqualityTester[]): boolean;
  buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
}

interface CustomEqualityTester {
  (first: any, second: any): boolean | void;
}

interface EnvConfig {
  failSpecWithNoExpectations?: boolean;
  stopSpecOnExpectationFailure?: boolean;
  stopOnSpecFailure?: boolean;
  random?: boolean;
  verboseDeprecations?: boolean;
  forbidDuplicateNames?: boolean;
  throwOnExpectationFailure?: boolean;
  hideDisabled?: boolean;
}