{"record":{"id":"483b86f48e5c366e","repo":"jestjs/jest","slug":"each-must-be-called-with-an-array-or-tagged-tem","errorCode":null,"errorMessage":"`.each` must be called with an Array or Tagged Template Literal.\n\nInstead was called with: ${pretty(table, {maxDepth: 1, min: true})}\n","messagePattern":"`\\.each` must be called with an Array or Tagged Template Literal\\.\n\nInstead was called with: (.+?)\\)\\}\n","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-each/src/validation.ts","lineNumber":20,"sourceCode":" * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport chalk from 'chalk';\nimport type {Global} from '@jest/types';\nimport {format as pretty} from 'pretty-format';\n\ntype TemplateData = Global.TemplateData;\n\nconst EXPECTED_COLOR = chalk.green;\nconst RECEIVED_COLOR = chalk.red;\n\nexport const validateArrayTable = (table: unknown): void => {\n  if (!Array.isArray(table)) {\n    throw new TypeError(\n      '`.each` must be called with an Array or Tagged Template Literal.\\n\\n' +\n        `Instead was called with: ${pretty(table, {\n          maxDepth: 1,\n          min: true,\n        })}\\n`,\n    );\n  }\n\n  if (isTaggedTemplateLiteral(table)) {\n    if (isEmptyString(table[0])) {\n      throw new Error(\n        'Error: `.each` called with an empty Tagged Template Literal of table data.\\n',\n      );\n    }\n\n    throw new Error(\n      'Error: `.each` called with a Tagged Template Literal with no data, remember to interpolate with ${expression} syntax.\\n',\n    );","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-each/src/validation.ts#L2-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wrap the value in an array: `test.each([data])('...', ...)` if you intended a single-row table.","If the data should be an array, verify the source returns an array (check the import/require).","Use pretty-format output in the error to identify the actual type and shape of what was passed."],"exampleFix":"// before\nimport config from './config.json'; // config is an object\ntest.each(config)('key %s', (val) => { ... });\n\n// after\nimport entries from './entries.json'; // entries is an array\ntest.each(entries)('test %j', (entry) => { ... });","handlingStrategy":"type-guard","validationCode":"function assertArrayTable(table) {\n  if (!Array.isArray(table)) {\n    throw new TypeError(`Expected array, got ${typeof table}`);\n  }\n}","typeGuard":"function isNonEmptyArray(value: unknown): value is unknown[] {\n  return Array.isArray(value) && value.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Use TypeScript and annotate table variables with a typed array type.","Validate imported data shapes before passing to .each.","If data comes from JSON, assert its shape after import."],"tags":["jest-each","parameterized-tests","validation","type-error"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}