sinonjs / sinon

Test spies, stubs and mocks for JavaScript.
https://sinonjs.org/
Other
9.6k stars 769 forks source link

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

Closed DanKaplanSES closed 2 months ago

DanKaplanSES commented 2 months ago

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.

fatso83 commented 2 months ago

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 :)