Parameterized Tests: each & for in Vitest

From the Vitest cheat sheet ยท Test Structure ยท verified Nov 2026

Parameterized Tests: each & for

Run the same test or suite against a table of inputs

typescript
test.each([
  [1, 1, 2],
  [2, 3, 5],
])('add(%i, %i) -> %i', (a, b, expected) => {
  expect(add(a, b)).toBe(expected)
})

test.for([
  { a: 1, b: 1, sum: 2 },
])('add($a, $b) = $sum', ({ a, b, sum }) => {
  expect(add(a, b)).toBe(sum)
})
๐Ÿ’ก Prefer test.for: it exposes the test context for concurrent tests
๐Ÿ“Œ test.each spreads array rows into args; test.for passes the row
๐Ÿ” v5 no longer quotes strings in ${D}name titles: case a1, not 'a1'
โšก describe.each repeats a whole suite for every case
eachforparameterizeddata-driven

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet