How do I reset the called count on a Sinon spy before each test?
Here's what I'm doing now:
beforeEach(function() {
this.spied = sinon.spy(Obj.prototype, 'spiedMethod');
});
afterEach(function() {
Obj.prototype.spiedMethod.restore();
this.spied.reset();
});
But when I check the call count in a test:
it('calls the method once', function() {
$.publish('event:trigger');
expect(this.spied).to.have.been.calledOnce;
});
...the test fails and reports that the method was called X number of times (once for each previous test that also triggered the same event).