Bun

interface

test.Describe

interface Describe

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);
  });
});
  • each<T extends readonly [any, any]>(
    table: readonly T[]
    ): (label: DescribeLabel, fn: (...args: [...T[]]) => void | Promise<unknown>, options?: number | TestOptions) => void;

    Returns a function that runs for each item in table.

    @param table

    Array of Arrays with the arguments that are passed into the test fn for each row.

    each<T extends any[]>(
    table: readonly T[]
    ): (label: DescribeLabel, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void;
    each<T>(
    table: T[]
    ): (label: DescribeLabel, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
  • condition: boolean
    ): (label: DescribeLabel, fn: () => void) => void;

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

    This is the opposite of describe.skipIf().

    @param condition

    if these tests should run

  • label: DescribeLabel,
    fn: () => void
    ): void;

    Skips all other tests, except this group of tests.

    @param label

    the label for the tests

    @param fn

    the function that defines the tests

  • label: DescribeLabel,
    fn: () => void
    ): void;

    Skips this group of tests.

    @param label

    the label for the tests

    @param fn

    the function that defines the tests

  • condition: boolean
    ): (label: DescribeLabel, fn: () => void) => void;

    Skips this group of tests, if condition is true.

    @param condition

    if these tests should be skipped

  • label: DescribeLabel,
    fn?: () => void
    ): void;

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

    @param label

    the label for the tests

    @param fn

    the function that defines the tests

  • condition: boolean
    ): (label: DescribeLabel, fn: () => void) => void;

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

    @param condition

    if these tests should be skipped