“Updates to the AWS SDK v3 Client Mock to make my Jest testing easier you say? Sign us up!” Image credit at the end the article.

Updates to the AWS SDK v3 Client Mock

Over a year ago, I published this article about creating Jest unit tests for the AWS SDK v3 Client. Since writing the article, there have been some further developments which I’ll cover in this article. I thought it’s worth revisiting as I have been updating some old AWS SDK v2 code to use v3, and updating the Jest Unit Tests.

Kris Raven
Published in
4 min readJun 3, 2023

--

The closing sentence on the previous article was “…this could be an edge case and maybe it might be made prettier, and more Jest-like in future iterations”. Not a strong statement, but I didn’t want to be too controversial; it’s a decent library. This statement was in reference to having to navigate a call and find what was sent to the client (for example on line 28 in the image below; s3ClientMock.call(0).args[0].input). This is what I want to cover first.

An additional library is needed to make it prettier. The library is called aws-sdk-client-mock-jest. It’s been published by the same author of the aws-sdk-client-mock and introduces custom Jest…

--

--

Kris Raven
CodeX
Writer for

Quality Engineering Manager | A wholesome mix of QA, Automated Testing, music and philosophy | Enjoys unit tests | Favours integration tests