Lifecycle Hook
A callback that runs at a defined point in a test's lifecycle, such as before or after execution, for setup and cleanup.
What is Lifecycle Hook?
What is Lifecycle Hook?
A lifecycle hook is a function the test framework invokes at a specific moment—before each test, after each test, before or after an entire suite—so you can prepare and tear down state reliably. Hooks keep individual tests clean and independent by pulling repetitive setup (logging in, seeding data) and cleanup (resetting state, closing resources) out of the test body. Proper use of lifecycle hooks is fundamental to test isolation and repeatability, ensuring every recorded flow starts from a known state and leaves nothing behind.