Skip to content

Glossary: Testing Web Apps

Spy

Also written: spies, vi.spyOn, vi.restoreAllMocks, mockRestore

A wrapper that watches a real function and can replace what it returns. `vi.spyOn(Math, "random")` makes randomness predictable, and `vi.restoreAllMocks()` puts the real one back.

Where the book teaches it

Related terms

MockFlaky test