Support for jest-mock-extended's calledWith mocks #327
laurence-hudson-mindfoundry
started this conversation in
Ideas
Replies: 1 comment
-
|
Hello @laurence-hudson-mindfoundry 👋 That is actually a very good and interesting idea. I'm familiar with I hope to provide an update here soon! Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
Is your feature request related to a problem? Please describe it
In jest-mock-extended there is a
mockFnthat can be used as a replacement forjest.fn. It produces mocks that have a.calledWithinterface for more fluent mocking, i.e.thisMock.doSomething.calledWith(123).mockReturnValue(456). Currently the mocks created by automock are vanilla jest mocks. It would be really nice to be able to get mocks withcalledWithvia the TestBedunitRef.getinterface (with type safey).Describe the solution you'd like
jest-mock-extended's
MockProxytype (which includes calledWith) appears be a sub type of vanilla jest mocks, so it might be plausible to adopt it for all of automock's jest mocking without breaking changes. But it would probably be cleaner to add a "mocker" argument to TestBed (although the generic typing required for this might get ugly).What is the motivation / use case for changing the behavior?
Gain the advantages of both automock and jest-mock-extended without loosing the cleanness of automock's interfaces.
Beta Was this translation helpful? Give feedback.
All reactions