Sinon.JS - Standalone test spies, stubs and mocks for JavaScript. Works with any unit testing framework.

Sinon.JS Documentation Releases How To Works with any unit testing framework. Get Started Star Sinon.JS on Github Proudly Backed By Become a backer and support Sinon.JS with a monthly donation. Become a backer npm To install the current release ( v2.3.1 ) of Sinon: npm install sinon If you (for some reason) really want the old version of Sinon, head over to the legacy docs and do: npm install sinon@1 The following function takes a function as its argument and returns a new function. You can call the resulting function as many times as you want, but the original function will only be called once: function once(fn) { var returnValue, called = false; return function () { if (!called) { called = true; returnValue = fn.apply(this, arguments); } return returnValue; }; } Testing this fun...

Linked on 2017-05-25 00:51:52 | Similar Links