FbeforeAll
Bun

function

test.beforeAll

function beforeAll(
fn: () => void | Promise<unknown> | (done: (err?: unknown) => void) => void
): void;

Runs a function, once, before all the tests.

This is useful for running set up tasks, like initializing a global variable or connecting to a database.

If this function throws, tests will not run in this file.

@param fn

the function to run

let database;
beforeAll(async () => {
  database = await connect("localhost");
});