标签:method class origin nal code ati original als span
We can use ‘jest.spyOn‘, similr to ‘spyOn‘ in Jasmine.
jest.spyOn(utils, ‘getWinner‘)
We get ‘getWinner‘ as a method.
Jest has mockImplementation:
// from utils.getWinner = jest.fn((p1, p2) => p2) // to utils.getWinner.mockImplementation((p1, p2) => p2)
We can also do the cleanup after the test:
// cleanup utils.getWinner.mockRestore()
[Jest] Restore the Original Implementation of a Mocked JavaScript Function with jest.spyOn
标签:method class origin nal code ati original als span
原文地址:https://www.cnblogs.com/Answer1215/p/12808917.html