sinonjs / sinon

Test spies, stubs and mocks for JavaScript.

Home Page:https://sinonjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove `const sandbox = sinon.createSandbox();` from examples unrelated to `sandbox`.

DanKaplanSES opened this issue · comments

Is your feature request related to a problem? Please describe.
Many of the examples start with const sandbox = sinon.createSandbox(); and then use that sandbox object. According to the sandbox documentation, "Since Sinon 5, the sinon object is a default sandbox in itself! Unless you have a very advanced setup or need a special configuration, you probably only need to use that one in your tests for easy cleanup."

If the reader doesn't read this quote, the examples imply that you should use const sandbox = sinon.createSandbox(); in your tests, too.

Describe the solution you'd like
I'd like the non-sandbox examples to remove sandbox from their code.

Describe alternatives you've considered

  1. This issue could be closed without change.
  2. I suppose a comment could be added to every one of these lines to say // or use sinon instead?

Additional context
I'm willing to create a PR for this. I just wanted to make sure it is a good idea before I attempt to.

This is absolutely correct. I just had to understand what you were talking about. Seeing that it was just a handful of examples, I just fixed it :)