Skip to main content
Create mocks with the mock function from bun:test.
test.ts

The mock function can accept arguments.
test.ts

The result of mock() is a new function that’s been decorated with some additional properties.
test.ts

These extra properties make it possible to write expect assertions about usage of the mock function, including how many times it was called, the arguments, and the return values.
test.ts

See Docs > Test Runner > Mocks for complete documentation on mocking with the Bun test runner.