CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jasmine

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

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

sequential-runner.mddocs/

Sequential Test Execution

The Jasmine class provides single-process test execution with full jasmine-core integration, offering complete control over test execution, custom matchers, and flexible configuration.

Capabilities

Jasmine Class

Main test runner for sequential execution with comprehensive test suite management.

/**
 * Configures, builds, and executes a Jasmine test suite
 * @param options - Configuration options for the runner
 */
class Jasmine {
  constructor(options?: JasmineOptions);
  
  /** The Jasmine environment from jasmine-core */
  readonly env: Env;
  
  /** Whether to cause the Node process to exit when the suite finishes executing */
  exitOnCompletion: boolean;
  
  /** Get the version of jasmine-core in use */
  coreVersion(): string;
}

interface JasmineOptions {
  /** The path to the project's base directory */
  projectBaseDir?: string;
  /** Whether to create the globals (describe, it, etc) that make up Jasmine's spec-writing interface */
  globals?: boolean;
}

Test Execution

Run the complete test suite with optional file filtering and spec filtering.

/**
 * Runs the test suite
 * @param files - Spec files to run instead of the previously configured set
 * @param filter - Optional specification of what specs to run (RegExp, string, or path object)
 * @returns Promise that resolves when the suite completes
 */
execute(files?: string[], filter?: string | RegExp | FilterObject): Promise<JasmineDoneInfo>;

interface FilterObject {
  /** Array of spec or suite descriptions for path-based filtering */
  path: string[];
}

Usage Examples:

const Jasmine = require('jasmine');

const jasmine = new Jasmine();

// Run all specs
await jasmine.execute();

// Run specific files
await jasmine.execute(['spec/unit/my-spec.js', 'spec/integration/api-spec.js']);

// Run specs matching regex filter
await jasmine.execute(null, 'integration');
await jasmine.execute(null, /authentication/);

// Run specs at specific path
await jasmine.execute(null, {
  path: ['User management', 'Authentication', 'should validate credentials']
});

Test Suite Enumeration

List all suites and specs without executing them, useful for test discovery and tooling integration.

/**
 * Returns a tree of suites and specs without actually running the specs
 * @returns Promise resolving to enumerated test structure
 */
enumerate(): Promise<EnumeratedSuiteOrSpec[]>;

interface EnumeratedSuiteOrSpec {
  /** Type of the item */
  type: 'suite' | 'spec';
  /** Description of the suite or spec */
  description: string;
  /** Child items (only present for suites) */
  children?: EnumeratedSuiteOrSpec[];
}

Usage Example:

const jasmine = new Jasmine();
await jasmine.loadConfigFile();

const structure = await jasmine.enumerate();
console.log(JSON.stringify(structure, null, 2));

Test Randomization

Control test execution order with randomization and seeding capabilities.

/**
 * Sets whether to randomize the order of specs
 * @param value - Whether to randomize
 */
randomizeTests(value: boolean): void;

/**
 * Sets the random seed for reproducible test runs
 * @param seed - The random seed value
 */
seed(seed: string): void;

Usage Example:

const jasmine = new Jasmine();

// Enable randomization
jasmine.randomizeTests(true);

// Set specific seed for reproducible runs
jasmine.seed('12345');

await jasmine.execute();

Reporter Management

Add and manage custom reporters for test output and result processing.

/**
 * Add a custom reporter to the Jasmine environment
 * @param reporter - The reporter to add
 */
addReporter(reporter: Reporter): void;

/**
 * Clears all registered reporters
 */
clearReporters(): void;

/**
 * Provide a fallback reporter if no other reporters have been specified
 * @param reporter - The fallback reporter
 */
provideFallbackReporter(reporter: Reporter): void;

Usage Example:

const jasmine = new Jasmine();

// Add custom reporter
jasmine.addReporter({
  jasmineStarted: () => console.log('Tests started'),
  jasmineDone: (result) => console.log(`Tests completed: ${result.overallStatus}`),
  specDone: (result) => console.log(`Spec: ${result.description} - ${result.status}`)
});

await jasmine.execute();

Custom Matchers

Add custom matchers for enhanced test assertions within the current scope.

/**
 * Add custom matchers for the current scope of specs
 * Note: Only callable from within beforeEach, it, or beforeAll
 * @param matchers - Object where keys become new matcher names
 */
addMatchers(matchers: CustomMatchers): void;

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);
}

Execution Control

Configure test execution behavior for failure handling and spec stopping.

/**
 * Sets whether to cause specs to only have one expectation failure
 * @param value - Whether to cause specs to only have one expectation failure
 */
stopSpecOnExpectationFailure(value: boolean): void;

/**
 * Sets whether to stop execution of the suite after the first spec failure
 * @param value - Whether to stop execution after first spec failure
 */
stopOnSpecFailure(value: boolean): void;

Usage Example:

const jasmine = new Jasmine();

// Stop suite on first failure for fast feedback
jasmine.stopOnSpecFailure(true);

// Continue specs after first expectation failure
jasmine.stopSpecOnExpectationFailure(false);

await jasmine.execute();

Configuration and File Management

Load configuration and manage spec/helper files programmatically.

/**
 * Loads configuration from the specified file
 * @param configFilePath - Path to config file, defaults to spec/support/jasmine.json
 */
loadConfigFile(configFilePath?: string): Promise<void>;

/**
 * Loads configuration from the specified object  
 * @param config - Configuration object
 */
loadConfig(config: Configuration): void;

/**
 * Configure the test environment
 * @param envConfig - Environment configuration object
 */
configureEnv(envConfig: EnvConfig): void;

/**
 * Load spec files into the test suite
 */
loadSpecs(): Promise<void>;

/**
 * Load helper files into the test suite
 */
loadHelpers(): Promise<void>;

/**
 * Load required modules
 */
loadRequires(): Promise<void>;

Display and Output Control

Control test output formatting and verbosity.

/**
 * Sets whether to show colors in the console reporter
 * @param value - Whether to show colors
 */
showColors(value: boolean): void;

/**
 * Sets whether to run in verbose mode for debugging configuration problems
 * @param value - Whether to run in verbose mode  
 */
verbose(value: boolean): void;

/**
 * Sets whether the console reporter should list pending specs even when there are failures
 * @param value - Whether to always list pending specs
 */
alwaysListPendingSpecs(value: boolean): void;

Usage Example:

const jasmine = new Jasmine();

// Load configuration
await jasmine.loadConfigFile('config/test.json');

// Configure environment
jasmine.configureEnv({
  random: true,
  stopOnSpecFailure: false
});

// Set display options
jasmine.showColors(true);
jasmine.verbose(true);
jasmine.alwaysListPendingSpecs(false);

await jasmine.execute();

docs

cli.md

configuration.md

index.md

parallel-runner.md

reporting.md

sequential-runner.md

tile.json