jestjs/jest · error · TypeError
Shard / requested, but test sequencer in has no shard…
Error message
Shard ${globalConfig.shard.shardIndex}/${globalConfig.shard.shardCount} requested, but test sequencer ${Sequencer.name} in ${globalConfig.testSequencer} has no shard method. What it means
Thrown when the `--shard` CLI option (or `globalConfig.shard`) is used but the configured custom test sequencer class does not implement a `shard` method. Jest checks `typeof sequencer.shard !== 'function'` at runtime before attempting to call it, because sharding is an opt-in capability that custom sequencers must explicitly support.
Solutions
- Add a `shard` method to your custom sequencer class, or remove the custom `testSequencer` from config to use the default sequencer which supports sharding.
- If the custom sequencer is from a third-party package, upgrade it or check for a newer version that implements `shard`.
- Remove the `--shard` flag from the CI command if sharding is not needed.
Example fix
// before: CustomSequencer.js
const Sequencer = require('@jest/test-sequencer').default;
class CustomSequencer extends Sequencer {
sort(tests) { /* custom sort */ return tests; }
}
// after: add shard method
const Sequencer = require('@jest/test-sequencer').default;
class CustomSequencer extends Sequencer {
sort(tests) { /* custom sort */ return tests; }
shard(tests, { shardIndex, shardCount }) {
const shardSize = Math.ceil(tests.length / shardCount);
const shardStart = (shardIndex - 1) * shardSize;
return tests.slice(shardStart, shardStart + shardSize);
}
} Defensive patterns
Strategy: validation
Validate before calling
// Validate the custom sequencer supports sharding before running with --shard
const Sequencer = require('./CustomSequencer');
function validateSequencerShard(SequencerClass, hasShard) {
if (hasShard && typeof SequencerClass.prototype.shard !== 'function') {
throw new Error(`${SequencerClass.name} must implement shard(tests, options)`);
}
} Type guard
function hasShardMethod(seq: unknown): seq is { shard(tests: unknown[], shard: {shardIndex: number; shardCount: number}): Promise<unknown[]> } {
return typeof (seq as any)?.shard === 'function';
} Prevention
- If using --shard in CI, test the sharded run locally before pushing.
- When writing a custom sequencer, always extend @jest/test-sequencer and implement shard if you need sharding.
- Document in the sequencer file whether sharding is supported.
When it happens
Trigger: Running Jest with `--shard=1/4` (e.g. for CI parallelization) while `testSequencer` in the config points to a custom class that extends `@jest/test-sequencer` but does not define a `shard(tests, shardOptions)` method.
Common situations: Migrating from a non-sharded CI to a sharded one without updating a custom test sequencer. Using a third-party sequencer package that predates the sharding API. Adding `--shard` to CI scripts while a project-level custom sequencer is present.
Related errors
- Jest: Got error running
- The shard option / requires to be lower or equal than .
- The shard option requires 1-based values, received 0 or…
- The shard option requires a string in the format of
- Watch plugin configuration error
AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10).
Data as JSON: /api/errors/71cc7082e6749ce9.
Report an issue: GitHub.
Appendix: source
Thrown at packages/jest-core/src/runJest.ts:293
const matches = await getTestPaths(
globalConfig,
context.config,
searchSource,
outputStream,
changedFilesPromise && (await changedFilesPromise),
jestHooks,
filter,
);
allTests = [...allTests, ...matches.tests];
return {context, matches};
}),
);
performance.mark('jest/getTestPaths:end');
if (globalConfig.shard) {
if (typeof sequencer.shard !== 'function') {
throw new TypeError(
`Shard ${globalConfig.shard.shardIndex}/${globalConfig.shard.shardCount} requested, but test sequencer ${Sequencer.name} in ${globalConfig.testSequencer} has no shard method.`,
);
}
allTests = await sequencer.shard(allTests, globalConfig.shard);
}
allTests = await sequencer.sort(allTests);
if (globalConfig.onlyFailures) {
if (failedTestsCache) {
allTests = failedTestsCache.filterTests(allTests);
} else {
allTests = await sequencer.allFailedTests(allTests);
}
}
if (globalConfig.listTests) {
const testsPaths = [...new Set(allTests.map(test => test.path))];View on GitHub (pinned to 8e6d128e4a)