You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript will transpile it, my Intellij WebStorm IDE will show no error, it will even autocomplete functions on the non-instance "mock".
From my perspective, the mock generated by mock looks like the actual mock instance. So I was very confused and spent a few hours figuring out why I was not getting the actual mocked value but this ts-mockito "proxy" object.
I'd propose that ts-mockito should have proxy on every method and issue a "Did you forget to use instance?" hint if possible. It will not catch all cases but for the ones were the developer is calling methods on the proxy object, they would get a more straightforward hint and not a generic runtime TypeError: actualReturnValue.{whatEverWasCalled} is not a function.
The text was updated successfully, but these errors were encountered:
ts-mockito requires the use of
instance
(see: #87) to get the actual mocked object instance instead of a helper object. This is fine.I find its behavior strange though when used in a test-case when not used with
instance
. (I have asked and answered a question on StackOverflow about "How to mock a method using ts-mockito?" because of it.)
TypeScript will transpile it, my Intellij WebStorm IDE will show no error, it will even autocomplete functions on the non-instance "mock".
From my perspective, the mock generated by
mock
looks like the actual mock instance. So I was very confused and spent a few hours figuring out why I was not getting the actual mocked value but this ts-mockito "proxy" object.I'd propose that ts-mockito should have proxy on every method and issue a "Did you forget to use
instance
?" hint if possible. It will not catch all cases but for the ones were the developer is calling methods on the proxy object, they would get a more straightforward hint and not a generic runtimeTypeError: actualReturnValue.{whatEverWasCalled} is not a function
.The text was updated successfully, but these errors were encountered: