Testing & QA Output Prediction Hard +35 XP
beforeEach Purpose
What is beforeEach used for?
Testing & QARead-only
describe("UserService", () => {
beforeEach(() => {
db.clear();
});
});What is the output?
Show answer and explanation
Answer: Reset state before each test
beforeEach runs before every test in the describe block, ensuring each test starts with a clean, predictable state.
Hint: Each = every single test.
What this challenge tests
Output Prediction in Testing & QA: jest, test-lifecycle.