Per the docs:
Since sinon@5.0.0
You can reset history of all stubs using sinon.resetHistory()
To Reproduce
const assert = require('chai').assert;
const sinon = require('sinon');
describe('resetHistory', function() {
var num = null;
beforeEach(function() {
num = sinon.createStubInstance(Number);
});
afterEach(() => {
// Restore the default sandbox here
sinon.restore();
});
describe('called on individual stub method', function() {
it('should clear "called" status on stub', function() {
num.toFixed();
assert.isTrue(num.toFixed.called);
num.toFixed.resetHistory();
assert.isFalse(num.toFixed.called);
});
});
describe('called on module', function() {
it('should clear "called" status on all stubs', function() {
num.toFixed();
assert.isTrue(num.toFixed.called);
sinon.resetHistory();
assert.isFalse(num.toFixed.called);
});
});
});
RunKit demo
Actual results
Second test fails:
""called on module: should clear "called" status on all stubs: ❌. [assert.isFalse] Expected true to be false""
Expected results
All tests pass
Per the docs:
To Reproduce
RunKit demo
Actual results
Second test fails:
""called on module: should clear "called" status on all stubs: ❌. [assert.isFalse] Expected true to be false""
Expected results
All tests pass