jest.mock
在里面
should execute six commands
不影响
../src/execute
模块,因为它已在顶层导入。
开玩笑嘲弄
最高层已经开始嘲笑了
execute
开玩笑的间谍。最好使用
Once
不影响其他测试的实施:
it('should execute six commands', async () => {
execute.mockImplementationOnce(() => {
throw new Error('throwing here so. I can ensure the error parsed properly');
});
...
此外,模拟应该被强制为ES模块,因为
处决
名为导入:
jest.mock('../src/execute', () => ({
__esModule: true,
execute: jest.fn()
}))