Testing · Middle · Question 16 of 75
Why does vi.spyOn(module, "fn") often fail to affect calls inside the same ES module?
- ✓Correct answer: Internal calls use the local binding, not the exported object property, so the spy is bypassed
- 2Spies work only on classes
- 3ES modules can't be imported in tests
Explanation
Mock the module with vi.mock or move the dependency to another module / inject it.