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
790 stars 38 forks source link

toHaveReceivedCommand should throw an error if it receives a second parameter. #191

Closed shopsinc closed 9 months ago

shopsinc commented 10 months ago

It is very easy to write tests that will always pass if you incorrectly use toHaveReceivedCommand instead of toHaveReceivedCommandWith. It would be nice if toHaveReceivedCommand threw an error or warned you when you pass in a second parameter so you don't make that mistake.

This code will pass no matter what the second parameter is. It would be nice if it would save me from my own stupidity.

expect(schedulerMockClient).toHaveReceivedCommand(DeleteScheduleCommand, {
      Name: 'I AM BAD'
 })

It needs to be like this if you want it to actually fail.

expect(schedulerMockClient).toHaveReceivedCommandWith(DeleteScheduleCommand, {
      Name: 'I AM BAD'
 })
m-radzikowski commented 9 months ago

Good point. I've added a check in v3.1.0-beta.0. You can test it if you have a moment.

shopsinc commented 6 months ago

Thanks!