{"id":"30565ae7447f0436","repo":"jestjs/jest","slug":"not-enough-arguments-supplied-for-given-headings","errorCode":null,"errorMessage":"Not enough arguments supplied for given headings:\n${EXPECTED_COLOR(headings.join(' | '))}\n\nReceived:\n${RECEIVED_COLOR(pretty(data))}\n\nMissing ${RECEIVED_COLOR(missingData.toString())} ${pluralize('argument', missingData)}","messagePattern":"Not enough arguments supplied for given headings:\n(.+?)\n\nReceived:\n(.+?)\n\nMissing (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-each/src/validation.ts","lineNumber":61,"sourceCode":"      'Error: `.each` called with an empty Array of table data.\\n',\n    );\n  }\n};\n\nconst isTaggedTemplateLiteral = (array: any) => array.raw !== undefined;\nconst isEmptyTable = (table: Array<unknown>) => table.length === 0;\nconst isEmptyString = (str: string | unknown) =>\n  typeof str === 'string' && str.trim() === '';\n\nexport const validateTemplateTableArguments = (\n  headings: Array<string>,\n  data: TemplateData,\n): void => {\n  const incompleteData = data.length % headings.length;\n  const missingData = headings.length - incompleteData;\n\n  if (incompleteData > 0) {\n    throw new Error(\n      `Not enough arguments supplied for given headings:\\n${EXPECTED_COLOR(\n        headings.join(' | '),\n      )}\\n\\n` +\n        `Received:\\n${RECEIVED_COLOR(pretty(data))}\\n\\n` +\n        `Missing ${RECEIVED_COLOR(missingData.toString())} ${pluralize(\n          'argument',\n          missingData,\n        )}`,\n    );\n  }\n};\n\nconst pluralize = (word: string, count: number) =>\n  word + (count === 1 ? '' : 's');\n\nconst START_OF_LINE = '^';\nconst NEWLINE = '\\\\n';\nconst HEADING = '\\\\s*[^\\\\s]+\\\\s*';","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-each/src/validation.ts#L43-L79","documentation":"validateTemplateTableArguments checks that the number of interpolated `${...}` values is a multiple of the number of headings in a tagged-template table. If `data.length % headings.length !== 0`, the last row is incomplete, so jest-each reports how many arguments are missing rather than running malformed rows.","triggerScenarios":"A tagged-template table whose header declares N columns but whose interpolated values do not fill complete rows (e.g. 2 headers but 3 interpolations).","commonSituations":"Editing a table and deleting one interpolation but not its header; miscounting pipes in the header (a pipe inside a column value gets parsed as a separator); copy-paste that drops a cell.","solutions":["Re-count interpolations vs headings using the message's `headings` and `Missing N argument(s)` line.","Ensure every row has exactly one `${...}` per header column.","Escape literal `|` characters in column values or quote them, because `|` is the column delimiter.","Re-align the template literals one-per-line so missing cells are visually obvious."],"exampleFix":"// before\nit.each`\n  a | b | c\n  ${1} | ${2}\n`(...);\n\n// after\nit.each`\n  a | b | c\n  ${1} | ${2} | ${3}\n`(...);","handlingStrategy":"validation","validationCode":"// verify row completeness for tagged-template tables\nconst headings = headerLine.split('|').map(s => s.trim()).filter(Boolean);\nif (values.length % headings.length !== 0) {\n  throw new Error(`need rows of ${headings.length}, got ${values.length} values`);\n}","typeGuard":"const isCompleteRows = (headings: string[], vals: unknown[]) => headings.length > 0 && vals.length % headings.length === 0;","tryCatchPattern":null,"preventionTips":["Format tagged-template tables one row per line for visual alignment.","Escape literal pipes in cell values.","Generate tables from arrays to avoid manual counting."],"tags":["jest-each","parameterized-tests","tagged-template","validation"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}