test hooks
Functions a test runner calls around tests, such as beforeEach to set up fresh data and afterEach to clean it up.
In more detail
Hooks keep tests independent, so one test cannot leave behind state that breaks the next. before and after hooks run once for a whole suite rather than around each test.
Related terms
- test suite — A collection of tests run together to check a piece of software.
- teardown — Removing or releasing everything that was set up for a piece of work, from a test's open connections to a whole temporary environment, once it is no longer needed.
Taught in
- Native Test Runner: node:test & node:assert/strict — Node.js Internals & Backend Services