Skip to content

Latest commit

History

History
14 lines (10 loc) 路 524 Bytes

2021-04-14.md

File metadata and controls

14 lines (10 loc) 路 524 Bytes
publish_date
2021-04-14
  • Got some great advice from dev.to which has helped clear up my understanding of spies and mocks.

jest.mock() vs jest.spyOn() Looks like here you are using jest.mock() and jest.spyOn() here on the same function. Usually, these are used interchangeably, but not together.

Another good trick to properly type mock and mockResolvedValue. Simply cast to jest.Mock like so:

(axios.get as jest.Mock).mockResolvedValue(fakeResp);