【发布时间】:2018-02-19 20:58:41
【问题描述】:
我的测试目标中有当前导入:
import sharp from 'sharp'
并在我的同一个测试目标中使用它:
return sharp(local_read_file)
.raw()
.toBuffer()
.then(outputBuffer => {
在我的测试中,我在下面模拟尖锐的功能:
jest.mock('sharp', () => {
raw: jest.fn()
toBuffer: jest.fn()
then: jest.fn()
})
但我得到了:
return (0, _sharp2.default)(local_read_file).
^
TypeError: (0 , _sharp2.default) is not a function
有没有一种方法可以使用 Jest 模拟所有 Sharp 模块函数?
【问题讨论】:
标签: javascript node.js jestjs