Testing · Middle · Question 10 of 75
Why can vi.mock("./api") be written below the imports and still work?
- ✓Correct answer: Vitest hoists
vi.mockcalls to the top of the file, before the imports are evaluated - 2Imports are lazy in tests
- 3It doesn't work - the mock must be in a separate file
Explanation
jest.mock is hoisted by babel-jest the same way.