Skip to content

Glossary: JavaScript Beyond the Basics

Mock function

Also written: mock, vi.fn

A fake function made with `vi.fn()` that records every call so a test can check how it was used. It can also be told to return or reject a chosen value.

Where the book teaches it

Related terms

Dependency injectionTest double