Fill: afterEach Hook
Fill in the Blank Easy
Question
Fill in the blank to run cleanup after each test:
Code
___(() => {
// cleanup database
});
Hint
The hook name means 'after each test'.
Explanation
The correct answer is afterEach. This hook runs after every individual test, making it ideal for cleanup tasks like resetting a database, clearing mocks, or releasing resources.
Related Resources
Related Lessons
- Setup and Teardown
Test hooks for setup and cleanup.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.