Jest mock async function from default import

后端 未结 2 2031
-上瘾入骨i
-上瘾入骨i 2021-01-19 08:03

I\'m trying to mock an async function that is exported as a default export but all I get is TypeError: Cannot read property \'then\' of undefined

Wh

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 08:09

    You can mock anything with jest, like this jest.mock('@material-ui/core/withWidth', () => ({ __esModule: true, isWidthUp: jest.fn((a, b) => true), default: jest.fn(fn => fn => fn) }))

提交回复
热议问题