Wk-notes-11-18-jest-mock
jest api
jest.fn()
function spy, can track how many times the function being calledjest.mock()
can mock a module as imports
jest.mock('./LivePricingActions', () => ({
resetLivePricingData: jest.fn(),
fetchOneWayPrices: jest.fn(),
fetchReturnPrices: jest.fn(),
updateFlightSegment: jest.fn()
}));
[!! Once a module is mocked]: If an exported function in that module is invoked sometime in the test, it MUST be mocked as a jest.fn()
. Otherwise, the function will not be found.
Last updated
Was this helpful?