W3cubDocs

/Sinon.JS 7

General setup

We will be making fakes, spies and stubs. By default these are created in the default sandbox. Be sure to restore this sandbox after each test.

For example, if you’re using mocha you can place this in a test file at the root level:

afterEach(() => {
  // Restore the default sandbox here
  sinon.restore();
});

Or in Jasmine you should place it in each describe:

describe('My test suite', () => {

  afterEach(() => {
    // Restore the default sandbox here
    sinon.restore();
  });
});

Forgetting to restore your sandbox results in a memory leak.

For more advanced setups using multiple sandboxes, please see sandbox

© 2010–2018 Christian Johansen
Licensed under the BSD License.
https://sinonjs.org/releases/v7.1.1/general-setup