If I have a stub for a function that takes 2 callbacks, how can I wire up sinon.js to call both callbacks when the stubbed function is invoked?  For example - here's function that I want to stub which takes 2 functions as arguments:  function stu...
Consider the following jasmine spec:  describe("something.act()", function() {   it("calls some function of my module", function() {     var mod = require('my_module');     spyOn(mod, "someFunction");     something.act...
I want to upgrade my test suite to the latest Jasmine version 2.3.4. I have some custom helper methods for testing AngularJS stuff inside my spy_helper.js like this:  (function() {   this.stubPromise = function(service, functionName) {     var $q = j...
I am trying to stub the following:  on('complete', function(data){ });   I only want to call the callback if the first parameter is 'complete'.  The function I am testing also contains:  on('error', function(data){ });   So I...
In the last months I've been working with JavaScript and using SinonJS to stub some behaviours. I've manage to make it work, I've stubbed lots of methods and everything works great.  But I still have some questions about how Sinon works u...
I write a unit-test for doB function of my module.  I want to stub the function doA without exporting it, I prefer not change the way doB accesses doA.  I understand that it cannot be simply stubed because it isnt in the exported object.  How do I st...
I have a proxy module, which forwards function calls to services. I want to test if the service function is called, when a function in this proxy module is called.  Here is the proxy module:  const payService = require('../services/pay') cons...
I have sample code written below (which simplifies from my actual code implementation), the main idea of this simplified version, is to understand how can I stub the class for unit testing  I have Sensor class which is dependency injected into Contex...
A Sinon sandbox (or sinon instance) is passed from outside to script scope. Internal function (not a method) can be optionally spied/stubbed with Sinon sandbox.  Sinon is involved in some kind of monkey-patching here (not unit-testing) .Sinon sandbox...
I've got some code I'm trying to test with a structure like this (per Cleaning up sinon stubs easily):  function test1() {     // manually create and restore the sandbox     var sandbox;     beforeEach(function () {         sandbox = sinon.sa...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.