jestjs/jest · error · Error

Error: `.each` called with a Tagged Template Literal with no

Error message

Error: `.each` called with a Tagged Template Literal with no data, remember to interpolate with ${expression} syntax.

What it means

The tagged-template branch in validateArrayTable is also taken when the template has a non-empty first string but jest-each concludes there is no interpolated data. The fix message reminds the user that data must be supplied via `${expression}` interpolation inside the template; without interpolations the table has headings but zero rows.

Source

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

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',
    );
  }

  if (isEmptyTable(table)) {
    throw new Error(
      'Error: `.each` called with an empty Array of table data.\n',
    );
  }
};

const isTaggedTemplateLiteral = (array: any) => array.raw !== undefined;
const isEmptyTable = (table: Array<unknown>) => table.length === 0;
const isEmptyString = (str: string | unknown) =>
  typeof str === 'string' && str.trim() === '';

export const validateTemplateTableArguments = (
  headings: Array<string>,

View on GitHub (pinned to f49721c78e)

Solutions

  1. Add `${row}` interpolations after the header line, one per data row.
  2. If the data is in an array, switch to the array form `.each(rows)` instead of a tagged template.
  3. For array-of-objects data use `.each(rows)('...$field...', row => {})`.

Example fix

// before
it.each`
  a | b
`('$a/$b', ({a,b}) => {});

// after
it.each`
  a    | b
  ${1} | ${2}
  ${3} | ${4}
`('$a/$b', ({a,b}) => {});
Defensive patterns

Strategy: validation

Validate before calling

// ensure at least one interpolation slot when authoring tagged templates
const hasInterpolations = (strings: TemplateStringsArray, ...vals: unknown[]) => vals.length > 0;

Type guard

const hasRowData = (strings: TemplateStringsArray, vals: unknown[]) => vals.length > 0;

Prevention

When it happens

Trigger: Calling `.each\`a | b\`` — a header line with no `${...}` interpolations — so the `data` rest parameter is empty and there are no rows to iterate.

Common situations: Author writes the header row but forgets to interpolate row values; copy-paste of a header from documentation without filling in data; dynamic data computed but never interpolated into the template.

Related errors


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