-
Notifications
You must be signed in to change notification settings - Fork 29
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
Bring back spy.reset() #104
Comments
@AdamMcCormick can you use restore instead?
|
Any update on this issue? |
Hey @AdamMcCormick thanks for the issue. It was removed as it was seen to be an anti pattern because it swaps out internal state which can cause issues in tests - certainly compounding issues if your tests rely on external state. The preferred alternative is to @AdamMcCormick could you please give us some numbers as to how much slower your tests are by using restore? I'd be surprised to see even 100ms delta between restore/reset. |
You can just do
|
With let barSpy;
const foo = proxyquire("../lib/foo.js", {
"./bar.js": (...args) => barSpy(...args),
});
describe("foo bar", () => {
beforeEach(() => {
barSpy = chai.spy();
});
it("bar is called once by foo", () => {
foo();
expect(barSpy).to.have.been.called.once;
});
it("bar is called once by foo, again", () => {
foo();
expect(barSpy).to.have.been.called.once;
});
}); |
A previous issue #27 introduced the reset method to this library which we use extensively. It was removed in 1.0 for no clear reason. I'd like to see it put back
The text was updated successfully, but these errors were encountered: