Photo by Eric Er on Unsplash

On this page

Setup

Fakes, spies and stubs are created in the default sandbox which needs to be restored after each test to prevent memory leaks. We use a Mocha hook plugin for that:

// Restores the default sandbox after every test
exports.mochaHooks = {
afterEach() {
sinon.restore();
},
};

Types of test doubles

| Type | What it does | Behavior | Pre-programmed behavior | Pre-programmed expectations | When to use | |

Search articles

Type a word to search published articles.

Open the search page