Рет қаралды 40,230
#LETSMEETUP
💬 In this episode, a Senior Frontend Developer at Codete - Magda Kwiecień, will shed some light on using test mocks in one of the most popular JavaScript testing frameworks - Jest. From simple basics to a few lifehacks.
You can explore presented examples on Github:
github.com/kwieccia/jest-mock...
Chapters:
0:00 Intro
0:21 What is mock?
0:42 Why do we need mocks?
2:06 Use cases
2:38 jest.fn()
3:58 jest.spyOn()
5:47 jest.mock()
7:24 Global mocks
8:15 Different function mocks for each test case
9:08 Restore original function for a single test case
9:38 Deal with jest.mock() hoisting
Follow us 👉 / codete
Instagram 👉 / codete_career
Join us 👉 codete.com/career