jestjs/jest · error · Error

Jest: Transformers have not been loaded yet - make sure to r

Error message

Jest: Transformers have not been loaded yet - make sure to run `loadTransformers` and wait for it to complete before starting to transform files

What it means

Thrown by `_getTransformer` (ScriptTransformer.ts:311-315) when `_transformsAreLoaded` is still false. `loadTransformers()` is async and must complete before any file is transformed; if `_getTransformer` runs first, no transformer cache is populated and the guard fires rather than silently skipping configured transforms.

Source

Thrown at packages/jest-transform/src/ScriptTransformer.ts:312

            throw new TypeError(makeInvalidTransformerError(transformPath));
          }
          const res = {transformer, transformerConfig};
          const transformCacheKey = this._buildTransformCacheKey(
            this._cache.transformRegExp?.[i]?.[0].source ??
              new RegExp(transformPattern).source,
            transformPath,
          );
          this._transformCache.set(transformCacheKey, res);
        },
      ),
    );

    this._transformsAreLoaded = true;
  }

  private _getTransformer(filename: string) {
    if (!this._transformsAreLoaded) {
      throw new Error(
        'Jest: Transformers have not been loaded yet - make sure to run `loadTransformers` and wait for it to complete before starting to transform files',
      );
    }

    if (this._config.transform.length === 0) {
      return null;
    }

    const transformPatternAndPath = this._getTransformPatternAndPath(filename);
    if (!Array.isArray(transformPatternAndPath)) {
      return null;
    }

    const [transformPattern, transformPath] = transformPatternAndPath;
    const transformCacheKey = this._buildTransformCacheKey(
      transformPattern,
      transformPath,
    );

View on GitHub (pinned to f49721c78e)

Solutions

  1. Use the public async factory `createScriptTransformer(config)` which awaits `loadTransformers()` before returning.
  2. If constructing `ScriptTransformer` directly, `await transformer.loadTransformers()` before any `transformSource*` call.
  3. Audit custom runners/environments to ensure the transformer is fully loaded in their async setup phase.

Example fix

// before
const transformer = new ScriptTransformer(config);
transformer.transformSourceAsync(filename, source); // throws 209
// after
const transformer = await createScriptTransformer(config);
transformer.transformSourceAsync(filename, source);
Defensive patterns

Strategy: validation

Validate before calling

// Always go through the async factory; assert the flag before transforming
const transformer = await createScriptTransformer(config);
if (!transformer._transformsAreLoaded) throw new Error('loadTransformers not awaited');

Prevention

When it happens

Trigger: Calling `transformSource`/`transformSourceAsync` (or `requireAndTranspileModule`) on a `ScriptTransformer` instance that was constructed directly without awaiting `loadTransformers()`. Public factories like `createScriptTransformer` await it automatically; bypassing them or racing the load triggers this.

Common situations: A custom Jest runner/test environment that instantiates `ScriptTransformer` directly; a refactor that switched from `createScriptTransformer` to `new ScriptTransformer(...)` and forgot the await; an integration that constructs the transformer lazily but transforms a file before the load promise settles.

Related errors


AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03). Data as JSON: /data/errors/2ef1c4315269f058.json. Report an issue: GitHub.