Skip to content Skip to sidebar Skip to footer
Showing posts with the label Sinon

Stub A Standalone Module.exports Function Using Rewire

I am trying to stub a module.exports function. But I have some trouble. I will give you a sudo code… Read more Stub A Standalone Module.exports Function Using Rewire

How To Stub/mock Submodules Of A Require Of Nodejs Using Sinon

I am using sinon as for unit testing a nodejs(Hapijs) functionality. This function is in index.js. … Read more How To Stub/mock Submodules Of A Require Of Nodejs Using Sinon

Sinon Spy Function Called But Not Tracked

I am using Mocha and sinon to spy on a function call. The function is called correctly but the spy … Read more Sinon Spy Function Called But Not Tracked

Sinonjs - Advance Clock To 59 Minutes And Wait For 1 Minute Actually

I've a web component for auto-logout functionality which shows modal window with a message on 5… Read more Sinonjs - Advance Clock To 59 Minutes And Wait For 1 Minute Actually

Spying On Date Constructor With Sinon

I have a method that sets expiration date of a token: var jwt = require('jwt-simple'); modu… Read more Spying On Date Constructor With Sinon

Sinon Clock.tick Doesn't Advance Time For Settimeout

I am writing a test for an async function which performs a series of tasks and at one point waits f… Read more Sinon Clock.tick Doesn't Advance Time For Settimeout

Test Simple Logger Functions With Full Code Coverage

I'm using Chai, Sinon and Instanbul to test a NodeJS application. Here's the Logger code: i… Read more Test Simple Logger Functions With Full Code Coverage

Sinon Spy On Function Not Working

I'm trying to write a standalone test for this simple middleware function function onlyInternal… Read more Sinon Spy On Function Not Working

How To Mock Pg Pool With Sinon

In a previous project I mocked the mysql library with Sinon. I did this like so: X.js: const con =… Read more How To Mock Pg Pool With Sinon

Sinon Spy On Function Not Working

I'm trying to write a standalone test for this simple middleware function function onlyInternal… Read more Sinon Spy On Function Not Working

Sinon - Stubbing Function With Callback - Causing Test Method To Timeout

I have a method on a express route that looks like this: exports.register_post = function(req, res)… Read more Sinon - Stubbing Function With Callback - Causing Test Method To Timeout

Sinon: How To Stub An Entire Class, Rather Than Just A Method

I have a class under test that creates instances of another class. I want to stub out the entirety… Read more Sinon: How To Stub An Entire Class, Rather Than Just A Method

How To Spy A Function With Sinon.js That Is In The Same Js File As The Function Under Test

I have a problem with Sinon.js while trying to spy a function that is in the same javascript file a… Read more How To Spy A Function With Sinon.js That Is In The Same Js File As The Function Under Test

Sinon.JS Stub A Function That Resolves A Promise

I want to use Sinon to stub a function that uses callbacks which resolve a promise: const callback … Read more Sinon.JS Stub A Function That Resolves A Promise

Stubbing Window.location.href With Sinon

I am trying to test some client-side code and for that I need to stub the value of window.location.… Read more Stubbing Window.location.href With Sinon