There are two ways to get your hands on mock functions: Either by require()ing a mocked component (via jest.mock('moduleName')) or by explicitly requesting one from jest.fn() in your test:
因此,每当测试调用minus函数时,我都会尝试模拟一个函数,它执行模拟的函数
db.execute('SELECT `something` from `table`;');
我需要模拟mysql连接,这样我就可以使用它返回的任何内容来模拟对execute函数的调用。我尝试模拟整个mysql2/promise模块,但当然不起作用,因为模拟的createConnection不会返回任何可以调用execu
我试图模拟一个创建并返回另一个类的类。/src/ClassB“时,mockClassA未定义。
当使用babel-jest时,对模拟的调用将自动挂起到代码块的顶部。当我使用mock运行时,我得到了TypeError: mockClassA is not a constructor,因为mockClassA是未定义的,因为mock被悬挂在mockClassA的定义之上当我将mock更改为doMock时,它根本不<e