在使用Expect
进行测试过程中,遇到TypeError: expect.createSpy is not a function
该问题,那是因为:
This package has been donated to Jest. This means that all future development of expect v21+ will take place at facebook/jest.
因此,如果你使用的是21+版本,应该使用fest.fn
代替expect.createSpy
具体操作如下:
import jest from 'jest-mock';
const spy=fest.fn();
spy();
参考:https://stackoverflow.com/questions/46752389/typeerror-expect-createspy-is-not-a-function
https://stackoverflow.com/questions/46086970/getting-typeerror-jest-fn-is-not-a-function