Docs for .onCall may be inaccurate #1196

Open
jeznag opened this Issue Nov 25, 2016 · 0 comments

Projects

None yet

1 participant

@jeznag
jeznag commented Nov 25, 2016

We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.

  • Sinon version : v1.17
  • Environment : OSX
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?
Docs say you can do this:

stub
  .onCall(0).returns(someVar)
  .onCall(1).returns(someVar2)
  .returns(someOtherVarForAllCalls);

What actually happens
This doesn't work - the third call just returns a stubbed function rather than the return value for me.

What works is if I do

stub
  .returns(someOtherVarForAllCalls)
  .onCall(0).returns(someVar)
  .onCall(1).returns(someVar2);

How to reproduce

Describe with code how to reproduce the faulty behaviour,
or link to code on JSBin or similar

Output below shows the result of calling stub multiple times

no init 83 functionStub {} default
no init 84 functionStub {} default
no init 85 functionStub {} default
no init 86 functionStub {} default
no init 87 functionStub {} default
no init 88 functionStub {} default
no init 89 functionStub {} default
no init 90 functionStub {} default
no init 91 functionStub {} default
no init 92 functionStub {} default
no init 93 functionStub {} default
no init 94 functionStub {} default
no init 95 functionStub {} default
no init 96 functionStub {} default
no init 97 functionStub {} default
no init 98 functionStub {} default
no init 99 functionStub {} default
100
ERROR! TypeError: sandbox.dispose is not a function
at /Users/jeremy/Documents/dev/sideprojects/stryker/src/SandboxCoordinator.js:9:4125
at Array.map (native)
at /Users/jeremy/Documents/dev/sideprojects/stryker/src/SandboxCoordinator.js:9:4010

See this for an example

@jeznag jeznag referenced this issue in stryker-mutator/stryker Nov 25, 2016
Merged

Allow setting config for cpuCount #176

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