Run Jest tests in parallel shards for faster execution and improved performance.
Parallel Jest Runner is a utility for running Jest tests in parallel across multiple shards to significantly reduce test execution time in large projects. It handles test distribution, coverage reporting, and error aggregation automatically.
- Parallel Test Execution: Split tests into configurable shards for faster runs
- Coverage Reporting: Automatically merges coverage reports from all shards
- Smart Threshold Detection: Extracts coverage thresholds from your Jest config
- Detailed Error Reporting: Provides comprehensive failure summaries
- Configurable: Customize shards, memory limits, and more
npm install --save-dev parallel-jest-runner
npx parallel-jest-runner
-
-s, --shards <number>
- Number of shards to split tests into (default: 12) -
-m, --memory <number>
- Memory size in MB for Node process (default: 12288) -
-w, --workers <number>
- Max workers per shard (default: 1) -
-d, --dir <path>
- Working directory (default: current directory) -
-a, --args <string>
- Additional Jest arguments
import { runParallelTests } from 'parallel-jest-runner';
async function runTests() {
const result = await runParallelTests({
numShards: 8,
memorySize: 8192,
maxWorkers: 2,
workingDir: './my-project',
additionalJestArgs: ['--bail']
});
console.log('Tests passed:', result.success);
console.log('Test suites passed:', result.testSuitesPassed);
console.log('Tests passed:', result.testsPassed);
}
runTests();
- Faster CI Builds: Dramatically reduces test execution time
- Resource Optimization: Better utilization of multi-core systems
- Simplified Coverage: Handles coverage merging automatically
- Improved Reporting: Detailed failure information aggregated from all shards
- Node.js 14 or higher
- Jest 26 or higher
MIT