callCount does not convert from string
BebeSparkelSparkel opened this issue · 1 comments
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);
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.