1. sinon-sandbox
A testing utility for framework agnostic cleanup of sinon stubs
sinon-sandbox
Package: sinon-sandbox
Created by: wealthfront
Last modified: Sun, 26 Jun 2022 20:15:41 GMT
Version: 2.0.6
License: Apache-2.0
Downloads: 3,850
Repository: https://github.com/wealthfront/sinon-sandbox

Install

npm install sinon-sandbox
yarn add sinon-sandbox

sinon-sandbox

Build Status
devDependency Status
devDependency Status

Sinon-sandbox is a testing utility to make it easy to restore stubs after every test, agnostic of your team's testing framework of choice.

Installation

 $ npm install sinon-sandbox --save-dev

Usage

In order to restore your sinon stubs after every test, call restore in an afterEach hook.

 // in a file included at the beginning of your test suite
var sinon = require('sinon-sandbox');

afterEach(function() {
  sinon.restore();
})

When writing tests, require sinon-sandbox. Since it returns an instance of a sandbox, you can treat it just like the original sinon module.

 var sinon = require('sinon-sandbox');

sinon.stub().returns('a stubbed return value');

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code