FbeforeEach
Bun

function

test.beforeEach

function beforeEach(
fn?: HookFn,
options?: HookOptions
): void;

This function creates a hook that runs before each test in the current suite.

describe('tests', async () => {
  beforeEach(() => console.log('about to run a test'));
  it('is a subtest', () => {
    assert.ok('some relevant assertion here');
  });
});
@param fn

The hook function. If the hook uses callbacks, the callback function is passed as the second argument.

@param options

Configuration options for the hook.