Complete the code to run a setup function before all tests.
beforeAll(() => [1]);The beforeAll hook runs once before all tests. You put setup code like initializeDatabase() inside it.
Complete the code to run a cleanup function after each test.
afterEach(() => [1]);The afterEach hook runs after every test. It's good for cleanup like resetMocks() to keep tests independent.
Fix the error in the test lifecycle hook to properly close the server after all tests.
afterAll(() => [1]);The afterAll hook runs once after all tests. You should close resources like servers with server.close() here.
Fill both blanks to run setup before each test and cleanup after each test.
beforeEach(() => [1]); afterEach(() => [2]);
beforeEach runs before every test, so you initialize mocks there. afterEach runs after every test, so you clear mocks to keep tests clean.
Fill all three blanks to run setup once before all tests, setup before each test, and cleanup once after all tests.
beforeAll(() => [1]); beforeEach(() => [2]); afterAll(() => [3]);
beforeAll runs once to connect the database. beforeEach runs before each test to initialize mocks. afterAll runs once to disconnect the database.