CLI for Jasmine, a simple JavaScript testing framework for browsers and Node
npx @tessl/cli install tessl/npm-jasmine@5.10.0Jasmine 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.
npm install --save-dev jasmineconst Jasmine = require('jasmine');
const ParallelRunner = require('jasmine/parallel');
const { ConsoleReporter } = require('jasmine');For ES modules:
import Jasmine from 'jasmine';
import ParallelRunner from 'jasmine/parallel';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();Initialize a project:
npx jasmine initInstall examples:
npx jasmine examplesRun tests:
npx jasmine
npx jasmine spec/my-spec.js
npx jasmine --parallel=4
npx jasmine --filter="integration"Jasmine is built around several key components:
Jasmine class providing single-process test execution with full jasmine-core integrationParallelRunner class distributing specs across multiple worker processes for faster executionCore 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;
}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;
}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;
}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 outputBuilt-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;
}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;
}