I've got current import in my test target:
import sharp from 'sharp'
and using it with in my same test target:
return sharp(local_read_file)
.raw()
.toBuffer()
.then(outputBuffer => {
In my test, I'm doing below to mock sharp functions:
jest.mock('sharp', () => {
raw: jest.fn()
toBuffer: jest.fn()
then: jest.fn()
})
but I'm getting:
return (0, _sharp2.default)(local_read_file).
^
TypeError: (0 , _sharp2.default) is not a function
Is there a way we can mock all Sharp module functions using Jest with the function?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…