jestjs/jest · error · Error
Jest was unable to load the transformer defined for ${filena
Error message
Jest was unable to load the transformer defined for ${filename}. This is a bug in Jest, please open up an issue What it means
Thrown by `_getTransformer` (ScriptTransformer.ts:336-338) when `_transformsAreLoaded` is true and a transform pattern matched the filename, but `_transformCache.get(transformCacheKey)` returns undefined. The contract is that `loadTransformers` populates the cache for every configured entry; a miss means the cache key computed at lookup differs from the key computed at load - an internal Jest consistency failure.
Source
Thrown at packages/jest-transform/src/ScriptTransformer.ts:336
return null;
}
const transformPatternAndPath = this._getTransformPatternAndPath(filename);
if (!Array.isArray(transformPatternAndPath)) {
return null;
}
const [transformPattern, transformPath] = transformPatternAndPath;
const transformCacheKey = this._buildTransformCacheKey(
transformPattern,
transformPath,
);
const transformer = this._transformCache.get(transformCacheKey);
if (transformer !== undefined) {
return transformer;
}
throw new Error(
`Jest was unable to load the transformer defined for ${filename}. This is a bug in Jest, please open up an issue`,
);
}
private _instrumentFile(
filename: string,
input: TransformedSource,
canMapToInput: boolean,
options: ReducedTransformOptions,
): TransformedSource {
const inputCode = typeof input === 'string' ? input : input.code;
const inputMap = typeof input === 'string' ? null : input.map;
const result = babelTransform(inputCode, {
auxiliaryCommentBefore: ' istanbul ignore next ',
babelrc: false,
caller: {
name: '@jest/transform',View on GitHub (pinned to f49721c78e)
Solutions
- Confirm you are on a released Jest version (not a patched fork) and file the issue requested by the message if so.
- If you monkey-patch `config.transform` or `_transformCache` at runtime, stop - the cache is populated once at load time.
- Ensure `_buildTransformCacheKey` inputs (regex source, resolved transform path) are stable strings across calls.
Defensive patterns
Strategy: try-catch
Try / catch
// Internal consistency failure - catch, capture diagnostics, and report
try { transformer.transformSourceAsync(file, src); }
catch (e) {
if (/unable to load the transformer.*bug in Jest/.test(e.message)) {
captureState({ transform: config.transform, cache: [...transformer._transformCache.keys()] });
throw new Error('file a Jest issue: transformer cache miss after load', { cause: e });
}
throw e;
} Prevention
- Do not mutate `config.transform` or `_transformCache` after `loadTransformers()` completes.
- Use released Jest versions; if you fork, keep `_buildTransformCacheKey` inputs stable.
- Cache keys must depend only on the regex source string and the resolved transform path.
When it happens
Trigger: Requires `_buildTransformCacheKey` (which mixes the transform-pattern regex source and the transformPath) to be non-deterministic between the load loop (ScriptTransformer.ts:297-301) and the lookup (ScriptTransformer.ts:327-330) - e.g. a regex `source` that varies, or a transformPath that resolves differently across calls.
Common situations: Effectively unreachable in stock Jest; seen with monkey-patches that mutate `_config.transform` after load, or with a custom fork that changes cache-key construction. The message itself directs users to file a Jest issue.
Related errors
- "cwd" must be an absolute path. cwd: ${cwd}
- ● Invalid transformer module: "${slash(transformPath)}" sp
- Jest: Transformers have not been loaded yet - make sure to r
- ● Invalid return value: `process()` or/and `processAsync()
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/c8ef7a741edaaee6.json.
Report an issue: GitHub.