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 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'm trying to 'stub' a method via testdoubleJS to do a unit test for this method (doing npm test). It is the first time I'm doing this, so it is still hard to understand for me. For my attempt - shown below - I do get the error TypeEr...
before(function (func: (...args: any[]) => any) {   app = express();    // prepare environment   sandbox = sinon.createSandbox();    // stub   sandbox.stub(app, "post").callsFake(() => {     return Promise.resolve("send a post")...
I have been writing tests for the past couple of weeks now. At my place of work we are using Mocha as our test runner and Chai as an assertion library. I am also using Sinon for creating stubs and there is something that is bugging me constantly. I h...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.