Describe

Bun

Symbol

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: string, 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: string, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void
    each<T>(table: T[]): (label: string, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void
  • if(condition: boolean): (label: string, 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

  • only(label: string, 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

  • skip(label: string, fn: () => void): void

    Skips this group of tests.

    @param label

    the label for the tests

    @param fn

    the function that defines the tests

  • skipIf(condition: boolean): (label: string, fn: () => void) => void

    Skips this group of tests, if condition is true.

    @param condition

    if these tests should be skipped

  • todo(label: string, 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

  • todoIf(condition: boolean): (label: string, 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