Consecutive calls with expectation about args #1193

Open
mir3z opened this Issue Nov 19, 2016 · 0 comments

Projects

None yet

1 participant

@mir3z
mir3z commented Nov 19, 2016 edited

I want to create a mock with the following expectations:

  • it is called twice
  • on first call it is called with args <X> and returns <R1>
  • on second call it is called with args <Y> and returns <R2>

When I'm trying to do:

const mock = mock().twice();
mock.onCall(0).withArgs(0);
mock.onCall(1).withArgs(1);

I see error Defining a stub by invoking "stub.onCall(...).withArgs(...)" is not supported. Use "stub.withArgs(...).onCall(...)" to define sequential behavior for calls with certain arguments.

but if I follow the advice I'm unable to set different args and response for consecutive calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment