function it.eachTest
eachTest<T>(
testName: string,
dataset: EachData<T>,
callback: EachCallback<Assert, T>
): void

Defines one test per case of dataset, each receiving its case as data. Equivalent to QUnit.test.each, and names the cases as it does: name [value] for a short string, name [index: value] for other primitives, name [index] otherwise, and name [key] for an object dataset.

Examples

Example 1

import { module, test } from "qunitx";

module("Math", () => {
  test.each("is even", [2, 4, 6], (assert, n) => {
    assert.strictEqual(n % 2, 0);
  });
});

Type Parameters

Parameters

testName: string

Name shared by the cases.

dataset: EachData<T>

The cases.

callback: EachCallback<Assert, T>

Test body receiving (assert, data, { testName, options, context }).

Return Type

void