You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
write on board: jest.fn(factory), jest.mock(path, factory)
what are mocks
Mocking is a technique to isolate test subjects by replacing dependencies with objects that you can control. The goal for mocking is to replace something we don’t control with something we do
when to mock
how to create mocks with jest.fn() and jest.mock()
code-along template: https://github.com/thoughtworks-jumpstart/learn-mocking-and-stubbing
lesson outline:
jest.fn(factory)
,jest.mock(path, factory)
jest.fn()
andjest.mock()
jest gives us many ways to define a mock. see https://medium.com/@rickhanlonii/understanding-jest-mocks-f0046c68e53c for a comparison (note. it's using ES6 import syntax, so you have to map it to your CommonJS import/export syntax)
recap:
new Cat(brain, tail, coatOfFur, owner)
)The text was updated successfully, but these errors were encountered: