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 ParallelRunner class provides high-performance parallel test execution by distributing specs across multiple worker processes with automatic load balancing and result aggregation.
Parallel test runner distributing specs across multiple worker processes for faster execution.
/**
* Configures, builds, and executes a Jasmine test suite in parallel
* @param options - Configuration options for the parallel runner
*/
class ParallelRunner {
constructor(options?: ParallelRunnerOptions);
/** Whether to cause the Node process to exit when the suite finishes executing */
exitOnCompletion: boolean;
}
interface ParallelRunnerOptions {
/** The path to the project's base directory */
projectBaseDir?: string;
/** The number of worker processes to use */
numWorkers?: number;
/** Whether to create the globals (describe, it, etc) that make up Jasmine's spec-writing interface */
globals?: boolean;
}Execute tests across multiple worker processes with automatic spec distribution and result aggregation.
/**
* Runs the test suite in parallel across multiple workers
* @param files - Spec files to run instead of the previously configured set
* @param filterString - Regex used to filter specs (objects not supported in parallel mode)
* @returns Promise that resolves when the suite completes
*/
execute(files?: string[], filterString?: string): Promise<JasmineDoneInfo>;Usage Examples:
const ParallelRunner = require('jasmine/parallel');
// Basic parallel execution
const runner = new ParallelRunner({ numWorkers: 4 });
await runner.loadConfigFile();
await runner.execute();
// Run specific files in parallel
await runner.execute(['spec/unit/**/*.js', 'spec/integration/**/*.js']);
// Filter specs with regex (string only in parallel mode)
await runner.execute(null, 'integration');
// Auto-detect worker count
const autoRunner = new ParallelRunner({ numWorkers: require('os').cpus().length - 1 });
await autoRunner.execute();Control the number of worker processes and parallel execution behavior.
/**
* Sets whether to randomize the order of specs
* Note: Randomization cannot be disabled in parallel mode
* @param value - Must be true, throws error if false
*/
randomizeTests(value: boolean): void;
/**
* Sets the random seed
* Note: Random seed cannot be set in parallel mode
* @param seed - Not supported, throws error
*/
seed(seed: string): void;Important Notes:
Add and manage reporters that support parallel execution with proper capability validation.
/**
* Add a custom reporter to the parallel runner
* @param reporter - The reporter to add (must support parallel mode)
* @param errorContext - Optional context for error messages
*/
addReporter(reporter: ParallelReporter, errorContext?: string): void;
/**
* Clears all registered reporters
*/
clearReporters(): void;
interface ParallelReporter extends Reporter {
/** Required capability declaration for parallel support */
reporterCapabilities: {
parallel: true;
};
}Usage Example:
const ParallelRunner = require('jasmine/parallel');
const customReporter = {
reporterCapabilities: { parallel: true },
jasmineStarted: (options) => {
console.log(`Starting parallel execution with ${options.numWorkers} workers`);
},
jasmineDone: (result) => {
console.log(`Parallel execution completed in ${result.totalTime}ms using ${result.numWorkers} workers`);
},
specDone: (result) => {
// This will be called from all workers
console.log(`Spec completed: ${result.description}`);
}
};
const runner = new ParallelRunner({ numWorkers: 3 });
runner.addReporter(customReporter);
await runner.execute();Configure the test environment for parallel execution with restricted options.
/**
* Configure the test environment for parallel execution
* @param envConfig - Environment configuration (specFilter not supported)
*/
configureEnv(envConfig: ParallelEnvConfig): void;
interface ParallelEnvConfig {
/** Whether to fail specs that contain no expectations */
failSpecWithNoExpectations?: boolean;
/** Whether to stop each spec on the first expectation failure */
stopSpecOnExpectationFailure?: boolean;
/** Whether to stop suite execution on the first spec failure */
stopOnSpecFailure?: boolean;
/** Whether to run specs in a random order (always true in parallel) */
random?: boolean;
/** Whether to show verbose deprecation warnings */
verboseDeprecations?: boolean;
// Note: specFilter is not supported in parallel mode
}Usage Example:
const runner = new ParallelRunner({ numWorkers: 4 });
// Configure environment for parallel execution
runner.configureEnv({
stopOnSpecFailure: true, // Stop all workers on first failure
failSpecWithNoExpectations: true,
verboseDeprecations: false
});
await runner.execute();Important constraints and limitations when using parallel mode:
Unsupported Features:
specFilter functions (only string regex filters supported)reporterCapabilities.parallel: trueWorker Process Behavior:
Error Handling:
Usage Example with Error Handling:
const ParallelRunner = require('jasmine/parallel');
const runner = new ParallelRunner({ numWorkers: 4 });
// Set exit behavior
runner.exitOnCompletion = false; // Handle results programmatically
try {
const result = await runner.execute();
if (result.overallStatus === 'failed') {
console.error('Tests failed:', result.failedExpectations);
process.exit(1);
} else {
console.log(`Tests passed in ${result.totalTime}ms using ${result.numWorkers} workers`);
}
} catch (error) {
console.error('Fatal error during parallel execution:', error);
process.exit(1);
}Load configuration and manage spec/helper files for parallel execution.
/**
* 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;Control test output formatting and verbosity for parallel execution.
/**
* 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 ParallelRunner = require('jasmine/parallel');
const runner = new ParallelRunner({ numWorkers: 4 });
// Load configuration
await runner.loadConfigFile('config/parallel-test.json');
// Set display options
runner.showColors(true);
runner.verbose(true);
runner.alwaysListPendingSpecs(false);
await runner.execute();