DEV Community

Discussion on: Mocking AWS with Jest (and TypeScript)

Collapse
 
brett_ryan_c987792fff6b8d profile image
Brett Ryan • Edited

This is an excellent article. In the last example for Returning Data, should the mock return value not be a promise?

awsSdkPromiseResponse.mockReturnValueOnce({ Item: fluffy });
Enter fullscreen mode Exit fullscreen mode

might be the following?

awsSdkPromiseResponse.mockReturnValueOnce(Promise.resolve({
  Item: fluffy
});
Enter fullscreen mode Exit fullscreen mode
Collapse
 
elthrasher profile image
Matt Morgan

Thanks for reading, Brett and good catch. It works the way I had it because you can await 'hello' but it's more accurate to have the Promise there.