m-radzikowski / aws-sdk-client-mock

AWS JavaScript SDK v3 mocks for easy unit testing. 🖋️ Typed 🔬 Tested 📄 Documented 🛠️ Maintained
https://m-radzikowski.github.io/aws-sdk-client-mock/
MIT License
812 stars 40 forks source link

Documentation example for __mocks__ implementation #229

Open mdpratt opened 5 months ago

mdpratt commented 5 months ago

This package makes mocking on a spec by spec significantly easier. However sometimes I would like to mock a client with a default behavior across many packages; for example, mocking STS' GetCallerIdentityCommand. Some documentation on how to put this into a toplevel __mocks__ would be appreciated.

If I figure it out, I'll open a pull request, but automocks is something that trips me up almost every time getting it just right.

m-radzikowski commented 2 months ago

I'm unsure if using (Jest) __mocks__ dir is a solution here because it replaces local modules with mocks. What you can try is maybe setting mock behavior in setupFilesAfterEnv script? If you make it work, please share.

crs1138 commented 3 weeks ago

@mdpratt if you do work it out, could you mention it here please?