method

test.Test.serialIf

condition: boolean
): Test<T>;

Forces the test to run serially (not in parallel), if condition is true. This applies even when the --concurrent flag is used.

@param condition

if the test should run serially

Referenced types

interface Test<T extends ReadonlyArray<unknown>>

Runs a test.

test("can check if using Bun", () => {
  expect(Bun).toBeDefined();
});

test("can make a fetch() request", async () => {
  const response = await fetch("https://example.com/");
  expect(response.ok).toBe(true);
});

test("can set a timeout", async () => {
  await Bun.sleep(100);
}, 50); // or { timeout: 50 }
  • concurrent: Test<T>

    Runs the test concurrently with other concurrent tests.

  • failing: Test<T>

    Marks this test as failing.

    Use test.failing for a test you expect to fail. The result is inverted: the test passes if it throws, and fails if it does not.

    test.failing is similar to test.todo except that it always runs, regardless of the --todo flag.

  • only: Test<T>

    Skips all other tests, except this test.

  • serial: Test<T>

    Forces the test to run serially (not in parallel), even when the --concurrent flag is used.

  • skip: Test<T>

    Skips this test.

  • todo: Test<T>

    Marks this test as to be written or to be fixed.

    These tests only run when the --todo flag is passed. With the flag, a .todo test that passes is marked as fail in the results: remove the .todo or check that the test is implemented correctly.

  • condition: boolean
    ): Test<T>;

    Runs the test concurrently with other concurrent tests, if condition is true.

    @param condition

    if the test should run concurrently

  • each<T extends unknown[]>(
    table: readonly T[]
    ): Test<T>;
    each<T>(
    table: T[]
    ): Test<[T]>;
  • condition: boolean
    ): Test<T>;

    Marks this test as failing, if condition is true.

    @param condition

    if the test should be marked as failing

  • condition: boolean
    ): Test<T>;

    Runs this test, if condition is true.

    This is the opposite of test.skipIf().

    @param condition

    if the test should run

  • condition: boolean
    ): Test<T>;

    Forces the test to run serially (not in parallel), if condition is true. This applies even when the --concurrent flag is used.

    @param condition

    if the test should run serially

  • condition: boolean
    ): Test<T>;

    Skips this test, if condition is true.

    @param condition

    if the test should be skipped

  • condition: boolean
    ): Test<T>;

    Marks this test as to be written or to be fixed, if condition is true.

    @param condition

    if the test should be marked TODO