NagRock / ts-mockito

Mocking library for TypeScript
MIT License
969 stars 93 forks source link

Visibility/log on arguments mismatch in function call #210

Open dorgalam opened 3 years ago

dorgalam commented 3 years ago

Hi! Been using ts-mockito quite a bit now, and really liking it. My biggest issue though, is when you're mocking isn't the same as actual function calls, and I have no idea why. It would be extremely helpful if each matcher was also able to let you know why it failed, and then log it.

If that sounds like something you want in this package, I wouldn't mind contributing it myself

My idea in a nutshell, is to add another method to Matcher class that returns string log on why something didn't pass, and if the .every() call returns false, then call each matcher's whatWentWrong function and finally output everything to some debug.info log.

albertodiazdorado commented 1 year ago

The library is unusable without this feature IMO

I am too tired of writing

expect(capture(method).last()[0]).toEqual(expectedArgs)

Everytime a test turns red. I understand that this is open source and probably none ever had time to write a proper implementation, but none who is sane would believe that the current design is desirable in any sense.