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
- Add `${row}` interpolations after the header line, one per data row.
- If the data is in an array, switch to the array form `.each(rows)` instead of a tagged template.
- 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
- After writing the header, immediately add at least one ${row} line.
- Prefer the array form when data is already an array.
- Use a code generator for parameterized tables.
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
- Error: `.each` called with an empty Tagged Template Literal
- Not enough arguments supplied for given headings: ${EXPECTED
- Table headings do not conform to expected format: ${EXPECTE
- `.each` must only be called with an Array or Tagged Template
- `.each` must be called with an Array or Tagged Template Lite
AI-assisted analysis of jestjs/jest@f49721c78e (2026-08-03).
Data as JSON: /data/errors/875170f367bff26c.json.
Report an issue: GitHub.