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...
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...
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...
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...
I am a bit confused while writing tests. My stack is mocha, chai and sinon + babel to transpile. And recently I've started to use ES6 imports and exports. It's working great so far, but I have trouble with mocking some dependencies. Here is m...
I'm running selenium tests for a react app, and I'm trying to stub my axios (XHR) requests. Ithink I'm close but seems like there's something missing. I'm running polly l - listening on localhost:3000 - and then my test looks like...
I need to rename a number of javascript functions but for compatibility also need to keep the old name.  I can think of 2 ways:   create stub functions function oldFunction(a,b,c) { newFunction(a,b,c) } or use function expressions var oldFunction = n...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.