Top "Sinon" questions

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

Spying on a constructor in javascript with sinon

I am trying to create a spy on a constructor, and see if it gets called -- below are my …

javascript mocha sinon
Calling different callbacks for stub on firstcall and second call

I'm looking for a way in sinon to call different functions in first and second call to the stub method. …

sinon
sinon stub not replacing function.

I tried a dummy module and to stub it, but does not work. the app.js function foo() { return run_…

javascript node.js testing mocha sinon
Sinon spy on console.log call not registered

I'm trying to learn about Sinon and want to spy on console.log. The code is simple: function logToConsole() { console.…

javascript testing mocha sinon chai
sinon spy on standalone function

When I use Sinon on a function inside an object, it works: function myFunc() { console.log('hello'); } var myObj = { myFunc: …

sinon
Catching thrown errors with SinonJS

I've got a method that may throw an Error, but I'm having trouble writing a SinonJS/Mocha/Should unit test …

node.js unit-testing mocha.js sinon should.js
Stubbing a React component method with Sinon

I'm trying to stub a React component method for testing purpose: var Comp = React.createClass({ displayName: "Comp", plop: function() { console.…

javascript reactjs stub sinon
Mocking/stubbing Mongoose model save method

Given a simple Mongoose model: import mongoose, { Schema } from 'mongoose'; const PostSchema = Schema({ title: { type: String }, postDate: { type: Date, default: …

node.js mongodb unit-testing mongoose sinon
How do I expect a function to be called with specific args with sinon, mocha, and chai in nodejs?

I have been having a problem trying to make sure Q.ninvoke is called with the args I am passing …

node.js mocha.js sinon chai sinon-chai
How to mock middleware in Express to skip authentication for unit test?

I have the following in Express //index.js var service = require('./subscription.service'); var auth = require('../auth/auth.…

node.js express mocha sinon proxyquire