You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
myApi is a wrapper for Google Api. So, I want to test mocking my Api. I usually use proxyquire but I don't know because you only pass the path and don't do a require. Do you have any clue?
The text was updated successfully, but these errors were encountered:
I was able to mock a dependency of my script by using mockery and sinon. Here's a snippet that shows an example:
constmockery=require('mockery');constsinon=require('sinon');constHelper=require('hubot-test-helper');constco=require('co');const{ expect }=require('chai');constprocessFn=sinon.stub();constmockApi={process: processFn};describe('script',()=>{beforeEach(()=>{consthelper=newHelper('./script.js');mockery.registerMock('./myApi'.js,mockApi);mockery.enable({warnOnUnregistered: false});this.room=helper.createRoom({httpd: false});});afterEach(()=>{this.room.destroy();processFn.reset();mockery.disable();});context('script',()=>{beforeEach(()=>{processFn.resolves('Hello!');returnco(function*(){yieldthis.room.user.say('brian','@hubot my regex');}.bind(this));});it('returns',()=>{expect(this.room.messages).to.equal([['brian','@hubot my regex'],['hubot','Hello!']]);});});});
Hi
My code looks like:
myApi is a wrapper for Google Api. So, I want to test mocking my Api. I usually use proxyquire but I don't know because you only pass the path and don't do a require. Do you have any clue?
The text was updated successfully, but these errors were encountered: