beforeEach()
Runs a setup function before each test in the current describe block. Use to reset state or create fixtures.
Syntax
testing
beforeEach(() => { /* setup */ })Example
testing
let db;
beforeEach(async () => {
db = await createTestDb();
await db.seed(testData);
});
afterEach(async () => {
await db.cleanup();
});