Back to Sinon

Getting started

docs/getting-started.md

22.1.0933 B
Original Source

Getting started

The examples will be using Node-Tap, which is the simplest complete test runner that is known to Sinon maintainers.

You can use Sinon with most popular test runners, such as Mocha, Jasmine, Jest, etc.

Installing

sh
npm install -D sinon

Using

<<< @/.vitepress/tests/docs/getting-started.test.js

Cleaning up after tests

In order to avoid memory leaks, which could lead to unpredictable test failures, it is recommended to restore Sinon's default sandbox after each test.

js
t.afterEach((t) => {
  sinon.restore();
});

For more advanced setups with sandboxes, please see the sandbox section.