flowforfrank / webtips

https://webtips.dev
1 stars 0 forks source link

webtips/jest/mock-promises-in-jest #33

Open utterances-bot opened 1 month ago

utterances-bot commented 1 month ago

How to Correctly Mock Promises in Jest - Webtips

In order to mock asynchronous code in Jest, more specifically Promises, you want to use the mockResolvedValue function with a return value.

https://webtips.dev/webtips/jest/mock-promises-in-jest

ragavendra commented 1 month ago

For some reason I was not able to assign the mock method to utils.fetch. I am getting TypeError: Cannot set property loadStaticCalendar of [object Object] which has only a getter. Otherwise without import for a method, this is working.