Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.to.have.been.called.with repeating params

See original GitHub issue

Hi, I am currently experiencing a strange issue with checking spies calls. It seems like it works only if checking calls with unique parameters, or I am using chai wrong which I would like to be pointed at.

To reproduce:

  it('checks spy calls with unique params', () => {
    const math = {
      multiply: function (a, b) {
        return a * b;

    const multiplyFunction = chai.spy.on(math, 'multiply');
    math.multiply(1, 2);
    chai.expect(multiplyFunction).to.have.been.called.with(1, 2);

  it('checks spy calls with repeating params', () => {
    const math = {
      multiply: function (a, b) {
        return a * b;

    const multiplyFunction = chai.spy.on(math, 'multiply');
    math.multiply(1, 1);
    chai.expect(multiplyFunction).to.have.been.called.with(1, 1);

First test always passes, while second fails, even if putting single 1 in expectation call params. Here is the error message:

AssertionError: expected { Spy, 1 call } to have been called with [ 1, 1 ]
    at assertWith (node_modules\chai-spies\lib\spy.js:280:12)
    at assert (node_modules\chai\lib\chai\utils\addChainableMethod.js:84:49)
    at Context.<anonymous> (....test.ts:79:59)
    at tryCatcher (core\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (core\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (core\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (core\node_modules\bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (core\node_modules\bluebird\js\release\promise.js:693:18)
    at Async._drainQueue (core\node_modules\bluebird\js\release\async.js:133:16)
    at Async._drainQueues (core\node_modules\bluebird\js\release\async.js:143:10)
    at Immediate.Async.drainQueues (core\node_modules\bluebird\js\release\async.js:17:14)

Also multiplyFunction.__spy field does have a call with params 1, 1

"__spy":  {
    "calls": [
    "called": true

Used versions:

"@types/chai-spies": "0.0.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"chai-spies": "^0.7.1",

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

stalniycommented, Jan 10, 2018

1.0.0 released! Hooray!

apricodercommented, Jan 10, 2018

Works as expected with 1.0.0 👍 Thanks everybody

Read more comments on GitHub >

github_iconTop Results From Across the Web

By-name repeated parameters - scala - Stack Overflow
How to pass by-name repeated parameters in Scala? The following code fails to work: scala> def foo(s: (=> String)*) ...
Read more >
unittest.mock — mock object library — Python 3.11.1 ...
assert the mock has been called with the specified arguments. ... Repeated calls to the mock will return values from the iterable (until...
Read more >
params keyword for parameter arrays - C# reference
When you call a method with a params parameter, you can pass in: A comma-separated list of arguments of the type of the...
Read more >
JavaScript: String repeat() method - TechOnTheNet
The repeat() method returns a string that has been repeated a desired number of times. If the count parameter is not provided or...
Read more >
OnceCallback<> and BindOnce(), RepeatingCallback<> and ...
Quick reference for binding parameters to BindOnce() and BindRepeating(). Passing Parameters Owned By The ... as if its Reset() method had been called....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found