method

test.Describe.for

for<T>(
table: readonly T[]
): Describe<[row: T]>;

Like each(), but an array row is passed as one argument instead of being spread.

headings: TemplateStringsArray,
...values: any[]
): Describe<[row: any]>;

Referenced types

interface Describe<T extends Readonly<any[]>>

Describes a group of related tests.

function sum(a, b) {
  return a + b;
}
describe("sum()", () => {
  test("can sum two values", () => {
    expect(sum(1, 1)).toBe(2);
  });
});
  • concurrent: Describe<T>

    Marks this group of tests to be executed concurrently.

  • only: Describe<T>

    Skips all other tests, except this group of tests.

  • sequential: Describe<T>

    Marks this group of tests to be executed serially (one after another).

  • serial: Describe<T>

    Marks this group of tests to be executed serially (one after another), even when the --concurrent flag is used.

  • shuffle: Describe<T>

    Runs the tests in this group and its nested groups in random order.

    The run summary prints the seed. Use bun test --seed=<seed> to get the same order again.

  • skip: (label: string | number) => void & Describe<T>

    Skips this group of tests.

  • todo: (label: string | number) => void & Describe<T>

    Marks this group of tests as to be written or to be fixed.

  • each<T extends readonly any[]>(
    table: readonly T[]
    ): Describe<[...T[]]>;
    each<T>(
    table: readonly T[]
    ): Describe<[T]>;
    headings: TemplateStringsArray,
    ...values: any[]
    ): Describe<[row: any]>;

    Takes the table as a tagged template. The first line names the columns, and each row is passed as an object.

  • for<T>(
    table: readonly T[]
    ): Describe<[row: T]>;

    Like each(), but an array row is passed as one argument instead of being spread.

    headings: TemplateStringsArray,
    ...values: any[]
    ): Describe<[row: any]>;
  • condition: boolean
    ): Describe<T>;

    Runs this group of tests, only if condition is true.

    This is the opposite of describe.skipIf().

    @param condition

    if these tests should run

  • condition: boolean
    ): Describe<T>;

    Runs this group of tests, only if condition is true.

  • condition: boolean
    ): Describe<T>;

    Skips this group of tests, if condition is true.

    @param condition

    if these tests should be skipped

  • condition: boolean
    ): Describe<T>;

    Marks this group of tests as to be written or to be fixed, if condition is true.

    @param condition

    if these tests should be marked TODO