Top "Sinon" questions

Sinon is a mocking framework for JavaScript, which can create spies, stubs and mocks.

Cleaning up sinon stubs easily

Is there a way to easily reset all sinon spys mocks and stubs that will work cleanly with mocha's beforeEach …

javascript testing mocha stubbing sinon
Stubbing a class method with Sinon.js

I am trying to stub a method using sinon.js but I get the following error: Uncaught TypeError: Attempted to …

javascript node.js sinon
How to mock localStorage in JavaScript unit tests?

Are there any libraries out there to mock localStorage? I've been using Sinon.JS for most of my other javascript …

javascript unit-testing mocking local-storage sinon
How does one stub promise with sinon?

I have a data service with following function function getInsureds(searchCriteria) { var deferred = $q.defer(); insuredsSearch.get(searchCriteria, function (insureds) { …

javascript jasmine sinon
Javascript: Mocking Constructor using Sinon

I am pulling my hair out trying to figure out how to mock a constructor using sinon. I have a …

javascript unit-testing constructor mocking sinon
Sinon error Attempted to wrap function which is already wrapped

Though there is a same question here but I could not find answer to my problem so here goes my …

node.js sinon
How to stub process.env in node.js?

I want to stub process.env.FOO with bar. var sinon = require('sinon'); var stub = sinon.stub(process.env, 'FOO', …

node.js stub sinon
Verifying function call and inspecting arguments using sinon spies

I would like to verify that bar() is called inside foo() from my unit test. I figured that Sinon spies …

javascript unit-testing sinon
How to unit test console output with mocha on nodejs?

Take into account the following example Javascript code below: function privateFunction (time) { if (time < 12) { console.log('Good morning'); } if (…

node.js unit-testing automated-tests mocha sinon
Can sinon stub withArgs match some but not all arguments

I have a function I am stubbing that gets called with multiple arguments. I want to check just the first …

sinon