jestjs/jest · error · TypeError

`.each` must be called with an Array or Tagged Template…

Error message

`.each` must be called with an Array or Tagged Template Literal.

Instead was called with: ${pretty(table, {maxDepth: 1, min: true})}

What it means

Thrown by `validateArrayTable` when the `.each` table argument is not an array at all. Unlike error 83 (which fires in the installer), this fires during deeper validation in the bind pipeline. It includes a pretty-format dump of the actual value received so the developer can see exactly what was passed.

Solutions

  1. Wrap the value in an array: `test.each([data])('...', ...)` if you intended a single-row table.
  2. If the data should be an array, verify the source returns an array (check the import/require).
  3. Use pretty-format output in the error to identify the actual type and shape of what was passed.

Example fix

// before
import config from './config.json'; // config is an object
test.each(config)('key %s', (val) => { ... });

// after
import entries from './entries.json'; // entries is an array
test.each(entries)('test %j', (entry) => { ... });
Defensive patterns

Strategy: type-guard

Validate before calling

function assertArrayTable(table) {
  if (!Array.isArray(table)) {
    throw new TypeError(`Expected array, got ${typeof table}`);
  }
}

Type guard

function isNonEmptyArray(value: unknown): value is unknown[] {
  return Array.isArray(value) && value.length > 0;
}

Prevention

When it happens

Trigger: Calling `.each` with a primitive, plain object, or `undefined`. The validation function `validateArrayTable` runs `Array.isArray(table)` and if it fails, throws this TypeError with a formatted representation of the offending value.

Common situations: Importing data from a JSON file and forgetting it parsed to an object. Passing a single fixture object instead of an array of fixtures. A module export changed shape and the variable is now an object.

Related errors


AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10). Data as JSON: /api/errors/483b86f48e5c366e. Report an issue: GitHub.

Appendix: source

Thrown at packages/jest-each/src/validation.ts:20

 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

import chalk from 'chalk';
import type {Global} from '@jest/types';
import {format as pretty} from 'pretty-format';

type TemplateData = Global.TemplateData;

const EXPECTED_COLOR = chalk.green;
const RECEIVED_COLOR = chalk.red;

export const validateArrayTable = (table: unknown): void => {
  if (!Array.isArray(table)) {
    throw new TypeError(
      '`.each` must be called with an Array or Tagged Template Literal.\n\n' +
        `Instead was called with: ${pretty(table, {
          maxDepth: 1,
          min: true,
        })}\n`,
    );
  }

  if (isTaggedTemplateLiteral(table)) {
    if (isEmptyString(table[0])) {
      throw new Error(
        'Error: `.each` called with an empty Tagged Template Literal of table data.\n',
      );
    }

    throw new Error(
      'Error: `.each` called with a Tagged Template Literal with no data, remember to interpolate with ${expression} syntax.\n',
    );

View on GitHub (pinned to 8e6d128e4a)