| Hook | Description |
|---|---|
beforeAll | Runs once before all tests. |
beforeEach | Runs before each test. |
afterEach | Runs after each test. |
afterAll | Runs once after all tests. |
Per-Test Setup and Teardown
Perform per-test setup and teardown logic withbeforeEach and afterEach.
Per-Scope Setup and Teardown
Perform per-scope setup and teardown logic withbeforeAll and afterAll. The scope is determined by where the hook is defined.
Scoped to a Describe Block
To scope the hooks to a particular describe block:Scoped to a Test File
To scope the hooks to an entire test file:Global Setup and Teardown
To scope the hooks to an entire multi-file test run, define the hooks in a separate file.--preload to run the setup script before any test files.
terminal
--preload every time you run tests, it can be added to your bunfig.toml:
bunfig.toml