Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callCount does not convert from string #136

Open
BebeSparkelSparkel opened this issue Dec 5, 2018 · 1 comment
Open

callCount does not convert from string #136

BebeSparkelSparkel opened this issue Dec 5, 2018 · 1 comment

Comments

@BebeSparkelSparkel
Copy link

Received the puzzling error
expected customer to have been called exactly 10 times, but it was called 10 times

To reproduce:

const {spy} = require('sinon'),
      chai = require('chai');
chai.should()
chai.use(require('sinon-chai'));

const n = '10',
      s = spy();
for(let i=0; i < n; ++i) s();

s.should.have.callCount(n);
@cincodenada
Copy link
Contributor

cincodenada commented Nov 2, 2021

Thanks for reporting this, and for the great simple test case! Sorry it's been so quiet around here. I'm not a maintainer here but I'm looking through issues while I've been digging around fixing other things, and dug in here as well.

That is indeed a rather absurd error message, I laughed a bit when I saw it because yes that is very confusing!

It looks like this is actually an issue with Sinon itself, this will get you the same error message:

const sinon = require('sinon');
const n = '10',
      s = sinon.spy();
for(let i=0; i < n; ++i) s();

sinon.assert.callCount(s, n);

I've filed a but reporting it upstream there - from a brief look I think it would be very difficult to work around this specifically in sinon-chai, and I think getting it fixed upstream is the correct move anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants