Mocked method arguments not allowed when verifying method was called
See original GitHub issueFirst of all, awesome library! Started looking at options for a new project yesterday and I’m already hooked.
I encountered one issue trying to verify that a method on a mock object has been called. I’m mocking Aurelia
class from the aurelia framework. See the type definition here: https://github.com/aurelia/framework/blob/master/dist/aurelia-framework.d.ts#L35
Calling setRoot(arg)
is allowed on the mock object but not when verifying that it has been called. The problem looks like this in my editor:
The two overloads for setRoot()
visible in intellisense look like this:
Aurelia.setRoot(...)
doesn’t really have overloads. But, the real one is not anymore available when calling setRoot()
after received()
:
Do you happen to know what could cause this issue?
Luckily, there is a workaround that allows the method to be called with an argument and the test to pass:
(aurelia.received(1) as Aurelia).setRoot("gui/suite-gui");
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Still investigating.
I’ve run into the same issue with the
Counter.inc()
method from https://www.npmjs.com/package/prom-client. In this case there are also two overloads, with one having a mandatory parameter and the other one having only optional parameters (https://github.com/siimon/prom-client/blob/master/index.d.ts#L183). The parameter I am passing is actually the mandatory one. Here’s a minimal example: