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
In this example, vi is globally exposed by vitest, but the expectation would be that jest.fn() and similars also work.
At the moment this is not possible, because myServiceMock is inferred strictly as MyService, instead of, let's say MyService & { doSomething: Mock<...> }.
What I'm doing at the moment to work around this is:
There is definitely something that could be done here:
fromPartial<MyService>()({doSomething: vi.fn()});
So, adding an overload to fromPartial that, when it receives no arguments, it returns a function. Then, in that second function call, you could infer from what's passed.
It's a question of whether the polymorphism of the API (and the resulting complexity) is worth it.
I'm not sure if this is even possible. I have tried a couple approaches in userland code, without successful results.
Basically, I would like to be able to do something like this:
At the moment this is not possible, because
myServiceMock
is inferred strictly asMyService
, instead of, let's sayMyService & { doSomething: Mock<...> }
.What I'm doing at the moment to work around this is:
But with this you loose a bit of context of what
doSomething
is, if you don't go back to the declaration and see it is being passed to the mock.The text was updated successfully, but these errors were encountered: