CLI for Jasmine, a simple JavaScript testing framework for browsers and Node
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
The Jasmine class provides single-process test execution with full jasmine-core integration, offering complete control over test execution, custom matchers, and flexible configuration.
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;
}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']
});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));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();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();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);
}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();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>;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();