C.W.K.
Stream
Quiz · 5 questions

🎭 Mocking: Faking Reality, Carefully

Functions, modules, time, and the network

Level 0Test Curious
0 XP0/32 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

Quiz

01What does vi.fn() return and what's it for?
02What's the difference between vi.fn() and vi.spyOn(obj, 'method')?
03Why does vi.mock('./api') need to be at the top of the file, not inside a beforeEach?
04When should you NOT mock something?
Hint
If the thing you're mocking runs in microseconds and is pure, the test usually reads better when you let it run for real.
05Why use fake timers (vi.useFakeTimers())?
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.