0

I'm using Sinon.js and set the requirement:

mock.expects("myFunc").withArgs("value", "value2", "2");

But then I get the following error:

Error: Unexpected call: myFunc(value, value2, 2)
Expected myFunc(value, value2, 2[, ...]) once (never called)

What does [, ...] mean? How can I get this to work?

user3179047
  • 324
  • 2
  • 12
  • It means that more (optional) arguments could have been passed to the function. See http://stackoverflow.com/questions/22668143/js-api-documentation-arg-vs-arg. – Felix Kling May 29 '14 at 17:30
  • What does it mean in the context of Sinon.js? I mocked it with exactly 3 arguments, and I called it with exactly 3 arguments. – user3179047 May 29 '14 at 17:39
  • The [documentation](http://sinonjs.org/docs/#mocks) says: *"`expectation.withArgs(arg1, arg2, ...);`: Expect the method to be called with the provided arguments and possibly others."* I assume the `[, ...]` represents the possible other arguments. There is also a function called `withExactArgs`: *"`expectation.withExactArgs(arg1, arg2, ...);` Expect the method to be called with the provided arguments and no others."* (Note: I never used Sinon and could be wrong). – Felix Kling May 29 '14 at 17:55

0 Answers0