stub never called with sinon and nodejs using chai-as-promised












0















i'm facing a issue with my unit test, stuck completely, the code is simple, please need to understand what's going on, my stub is never called, the set seems to be correct, here the code:



let strategy = fixtures.load('strategy')
chai.use(chaiAsPromised)

describe.only('Spawn Order Job', () => {

let getPositionsStub, createJobStub, daoStub,sandbox
beforeEach(()=>{
sandbox = sinon.createSandbox()
daoStub = sandbox.stub(dao, 'updateActiveOrders').resolves(true) //async
getPositionsStub = sandbox.stub(strategyModule, 'getPositions') //sync
createJobStub = sandbox.stub(helpers, 'createJob') //sync
createJobStub.returns(true)
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
})

afterEach(()=>{
sandbox.restore()
})
//OK
it('Should failed with no param, type error context', ()=> {
const promise = spawnOrderJob()
expect(promise).to.be.rejectedWith(TypeError)
})


//OK
it('Should throw error timeout order', () => {
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
strategy.lastDateOrder = new Date()
const ctx = { state: {strategy, dashboard, position:null}}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(getPositionsStub.called).to.be.true
expect(daoStub.called).to.be.false
expect(createJobStub.called).to.be.false
expect(promise).to.be.rejectedWith(ORDER_ERROR, 'Timeout between order not expired.')
})

//KO stub never called
it.only('Should pass validation on buy', () => {
strategy.lastDateOrder = 0
const ctx = { state: {strategy, dashboard, position: null }}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(promise).to.be.fulfilled
expect(getPositionsStub.called).to.be.true //ok
expect(createJobStub.called).to.be.true //never callled ????
expect(daoStub.called).to.be.true //never called ????
})
})


Want to understand what's going now there, the call are correct imo, running with mocha 5.2



Helpers.js : function is described as follow:



async function spawnOrderJob(action, ctx) {
try {
const { strategy, dashboard, position } = ctx.state
const {b, s} = action

//check in case strategy context
if (strategy) {
//pass validation buy contnext
if (b) {
//this stub is working
const positions = await strategyModule.getPositions(ctx)

const { maxPosition } = strategy.allocatedBTC
const { activeOrders, maxActiveOrders, timeBetweenOrder, lastDateOrder } = strategy

debug('Active orders:', strategy.activeOrders)
debug('Position:', positions.length)

if (activeOrders >= maxActiveOrders)
throw new ORDER_ERROR('Max active orders reach.')

if (positions.length + activeOrders >= maxPosition)
throw new ORDER_ERROR('Max positions reach.')

if (!timeoutExpired(lastDateOrder, timeBetweenOrder))
throw new ORDER_ERROR('Timeout between order not expired.')

//increment active orders counter
//stub fail, but not called at all
await dao.updateActiveOrders(strategy, true)
}

//Sell context
if (s) {
if (!position)
throw new ORDER_ERROR('No position to sell')
}
}
//stub fail, but called internally
return createJob(constants.DASHBOARD_CREATE_ORDER, {
orderType: b ? 'BUY' : 'SELL',
title: `Strategy create order ( ${ b ? 'BUY' : 'SELL'} )`,
strategy,
dashboard,
position
})
} catch (e) {
throw e
}
}


function createJob(name, data){
//shortcut queue.create (kue.js)
return queue.c(name,data)
}

module.exports = {
createJob,
spawnOrderJob
}


DAO



const updateActiveOrders = async (strategy, increment) => {
try {
const s = await model.findOne({_id: strategy._id})
if (!s) throw new Error('Strategy not found.')
s.activeOrders = increment ? s.activeOrders+1 :s.activeOrders-1
s.lastDateOrder = new Date()
return await s.save()
}catch(e){
throw e
}
}

module.exports = {updateActiveOrders}









share|improve this question

























  • I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

    – James
    Nov 22 '18 at 11:37











  • Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

    – Arthur
    Nov 22 '18 at 13:12













  • "is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

    – James
    Nov 22 '18 at 14:25








  • 1





    Yes it does, that was the problem :)

    – Arthur
    Nov 23 '18 at 11:48






  • 1





    Possible duplicate of Sinon not stubbing on module.exports

    – James
    Nov 23 '18 at 12:42
















0















i'm facing a issue with my unit test, stuck completely, the code is simple, please need to understand what's going on, my stub is never called, the set seems to be correct, here the code:



let strategy = fixtures.load('strategy')
chai.use(chaiAsPromised)

describe.only('Spawn Order Job', () => {

let getPositionsStub, createJobStub, daoStub,sandbox
beforeEach(()=>{
sandbox = sinon.createSandbox()
daoStub = sandbox.stub(dao, 'updateActiveOrders').resolves(true) //async
getPositionsStub = sandbox.stub(strategyModule, 'getPositions') //sync
createJobStub = sandbox.stub(helpers, 'createJob') //sync
createJobStub.returns(true)
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
})

afterEach(()=>{
sandbox.restore()
})
//OK
it('Should failed with no param, type error context', ()=> {
const promise = spawnOrderJob()
expect(promise).to.be.rejectedWith(TypeError)
})


//OK
it('Should throw error timeout order', () => {
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
strategy.lastDateOrder = new Date()
const ctx = { state: {strategy, dashboard, position:null}}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(getPositionsStub.called).to.be.true
expect(daoStub.called).to.be.false
expect(createJobStub.called).to.be.false
expect(promise).to.be.rejectedWith(ORDER_ERROR, 'Timeout between order not expired.')
})

//KO stub never called
it.only('Should pass validation on buy', () => {
strategy.lastDateOrder = 0
const ctx = { state: {strategy, dashboard, position: null }}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(promise).to.be.fulfilled
expect(getPositionsStub.called).to.be.true //ok
expect(createJobStub.called).to.be.true //never callled ????
expect(daoStub.called).to.be.true //never called ????
})
})


Want to understand what's going now there, the call are correct imo, running with mocha 5.2



Helpers.js : function is described as follow:



async function spawnOrderJob(action, ctx) {
try {
const { strategy, dashboard, position } = ctx.state
const {b, s} = action

//check in case strategy context
if (strategy) {
//pass validation buy contnext
if (b) {
//this stub is working
const positions = await strategyModule.getPositions(ctx)

const { maxPosition } = strategy.allocatedBTC
const { activeOrders, maxActiveOrders, timeBetweenOrder, lastDateOrder } = strategy

debug('Active orders:', strategy.activeOrders)
debug('Position:', positions.length)

if (activeOrders >= maxActiveOrders)
throw new ORDER_ERROR('Max active orders reach.')

if (positions.length + activeOrders >= maxPosition)
throw new ORDER_ERROR('Max positions reach.')

if (!timeoutExpired(lastDateOrder, timeBetweenOrder))
throw new ORDER_ERROR('Timeout between order not expired.')

//increment active orders counter
//stub fail, but not called at all
await dao.updateActiveOrders(strategy, true)
}

//Sell context
if (s) {
if (!position)
throw new ORDER_ERROR('No position to sell')
}
}
//stub fail, but called internally
return createJob(constants.DASHBOARD_CREATE_ORDER, {
orderType: b ? 'BUY' : 'SELL',
title: `Strategy create order ( ${ b ? 'BUY' : 'SELL'} )`,
strategy,
dashboard,
position
})
} catch (e) {
throw e
}
}


function createJob(name, data){
//shortcut queue.create (kue.js)
return queue.c(name,data)
}

module.exports = {
createJob,
spawnOrderJob
}


DAO



const updateActiveOrders = async (strategy, increment) => {
try {
const s = await model.findOne({_id: strategy._id})
if (!s) throw new Error('Strategy not found.')
s.activeOrders = increment ? s.activeOrders+1 :s.activeOrders-1
s.lastDateOrder = new Date()
return await s.save()
}catch(e){
throw e
}
}

module.exports = {updateActiveOrders}









share|improve this question

























  • I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

    – James
    Nov 22 '18 at 11:37











  • Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

    – Arthur
    Nov 22 '18 at 13:12













  • "is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

    – James
    Nov 22 '18 at 14:25








  • 1





    Yes it does, that was the problem :)

    – Arthur
    Nov 23 '18 at 11:48






  • 1





    Possible duplicate of Sinon not stubbing on module.exports

    – James
    Nov 23 '18 at 12:42














0












0








0


0






i'm facing a issue with my unit test, stuck completely, the code is simple, please need to understand what's going on, my stub is never called, the set seems to be correct, here the code:



let strategy = fixtures.load('strategy')
chai.use(chaiAsPromised)

describe.only('Spawn Order Job', () => {

let getPositionsStub, createJobStub, daoStub,sandbox
beforeEach(()=>{
sandbox = sinon.createSandbox()
daoStub = sandbox.stub(dao, 'updateActiveOrders').resolves(true) //async
getPositionsStub = sandbox.stub(strategyModule, 'getPositions') //sync
createJobStub = sandbox.stub(helpers, 'createJob') //sync
createJobStub.returns(true)
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
})

afterEach(()=>{
sandbox.restore()
})
//OK
it('Should failed with no param, type error context', ()=> {
const promise = spawnOrderJob()
expect(promise).to.be.rejectedWith(TypeError)
})


//OK
it('Should throw error timeout order', () => {
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
strategy.lastDateOrder = new Date()
const ctx = { state: {strategy, dashboard, position:null}}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(getPositionsStub.called).to.be.true
expect(daoStub.called).to.be.false
expect(createJobStub.called).to.be.false
expect(promise).to.be.rejectedWith(ORDER_ERROR, 'Timeout between order not expired.')
})

//KO stub never called
it.only('Should pass validation on buy', () => {
strategy.lastDateOrder = 0
const ctx = { state: {strategy, dashboard, position: null }}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(promise).to.be.fulfilled
expect(getPositionsStub.called).to.be.true //ok
expect(createJobStub.called).to.be.true //never callled ????
expect(daoStub.called).to.be.true //never called ????
})
})


Want to understand what's going now there, the call are correct imo, running with mocha 5.2



Helpers.js : function is described as follow:



async function spawnOrderJob(action, ctx) {
try {
const { strategy, dashboard, position } = ctx.state
const {b, s} = action

//check in case strategy context
if (strategy) {
//pass validation buy contnext
if (b) {
//this stub is working
const positions = await strategyModule.getPositions(ctx)

const { maxPosition } = strategy.allocatedBTC
const { activeOrders, maxActiveOrders, timeBetweenOrder, lastDateOrder } = strategy

debug('Active orders:', strategy.activeOrders)
debug('Position:', positions.length)

if (activeOrders >= maxActiveOrders)
throw new ORDER_ERROR('Max active orders reach.')

if (positions.length + activeOrders >= maxPosition)
throw new ORDER_ERROR('Max positions reach.')

if (!timeoutExpired(lastDateOrder, timeBetweenOrder))
throw new ORDER_ERROR('Timeout between order not expired.')

//increment active orders counter
//stub fail, but not called at all
await dao.updateActiveOrders(strategy, true)
}

//Sell context
if (s) {
if (!position)
throw new ORDER_ERROR('No position to sell')
}
}
//stub fail, but called internally
return createJob(constants.DASHBOARD_CREATE_ORDER, {
orderType: b ? 'BUY' : 'SELL',
title: `Strategy create order ( ${ b ? 'BUY' : 'SELL'} )`,
strategy,
dashboard,
position
})
} catch (e) {
throw e
}
}


function createJob(name, data){
//shortcut queue.create (kue.js)
return queue.c(name,data)
}

module.exports = {
createJob,
spawnOrderJob
}


DAO



const updateActiveOrders = async (strategy, increment) => {
try {
const s = await model.findOne({_id: strategy._id})
if (!s) throw new Error('Strategy not found.')
s.activeOrders = increment ? s.activeOrders+1 :s.activeOrders-1
s.lastDateOrder = new Date()
return await s.save()
}catch(e){
throw e
}
}

module.exports = {updateActiveOrders}









share|improve this question
















i'm facing a issue with my unit test, stuck completely, the code is simple, please need to understand what's going on, my stub is never called, the set seems to be correct, here the code:



let strategy = fixtures.load('strategy')
chai.use(chaiAsPromised)

describe.only('Spawn Order Job', () => {

let getPositionsStub, createJobStub, daoStub,sandbox
beforeEach(()=>{
sandbox = sinon.createSandbox()
daoStub = sandbox.stub(dao, 'updateActiveOrders').resolves(true) //async
getPositionsStub = sandbox.stub(strategyModule, 'getPositions') //sync
createJobStub = sandbox.stub(helpers, 'createJob') //sync
createJobStub.returns(true)
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
})

afterEach(()=>{
sandbox.restore()
})
//OK
it('Should failed with no param, type error context', ()=> {
const promise = spawnOrderJob()
expect(promise).to.be.rejectedWith(TypeError)
})


//OK
it('Should throw error timeout order', () => {
getPositionsStub.resolves([{fake:'t'}, {fake:'t'}])
strategy.lastDateOrder = new Date()
const ctx = { state: {strategy, dashboard, position:null}}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(getPositionsStub.called).to.be.true
expect(daoStub.called).to.be.false
expect(createJobStub.called).to.be.false
expect(promise).to.be.rejectedWith(ORDER_ERROR, 'Timeout between order not expired.')
})

//KO stub never called
it.only('Should pass validation on buy', () => {
strategy.lastDateOrder = 0
const ctx = { state: {strategy, dashboard, position: null }}
const action = {b: true, s: false}
const promise = spawnOrderJob(action, ctx)
expect(promise).to.be.fulfilled
expect(getPositionsStub.called).to.be.true //ok
expect(createJobStub.called).to.be.true //never callled ????
expect(daoStub.called).to.be.true //never called ????
})
})


Want to understand what's going now there, the call are correct imo, running with mocha 5.2



Helpers.js : function is described as follow:



async function spawnOrderJob(action, ctx) {
try {
const { strategy, dashboard, position } = ctx.state
const {b, s} = action

//check in case strategy context
if (strategy) {
//pass validation buy contnext
if (b) {
//this stub is working
const positions = await strategyModule.getPositions(ctx)

const { maxPosition } = strategy.allocatedBTC
const { activeOrders, maxActiveOrders, timeBetweenOrder, lastDateOrder } = strategy

debug('Active orders:', strategy.activeOrders)
debug('Position:', positions.length)

if (activeOrders >= maxActiveOrders)
throw new ORDER_ERROR('Max active orders reach.')

if (positions.length + activeOrders >= maxPosition)
throw new ORDER_ERROR('Max positions reach.')

if (!timeoutExpired(lastDateOrder, timeBetweenOrder))
throw new ORDER_ERROR('Timeout between order not expired.')

//increment active orders counter
//stub fail, but not called at all
await dao.updateActiveOrders(strategy, true)
}

//Sell context
if (s) {
if (!position)
throw new ORDER_ERROR('No position to sell')
}
}
//stub fail, but called internally
return createJob(constants.DASHBOARD_CREATE_ORDER, {
orderType: b ? 'BUY' : 'SELL',
title: `Strategy create order ( ${ b ? 'BUY' : 'SELL'} )`,
strategy,
dashboard,
position
})
} catch (e) {
throw e
}
}


function createJob(name, data){
//shortcut queue.create (kue.js)
return queue.c(name,data)
}

module.exports = {
createJob,
spawnOrderJob
}


DAO



const updateActiveOrders = async (strategy, increment) => {
try {
const s = await model.findOne({_id: strategy._id})
if (!s) throw new Error('Strategy not found.')
s.activeOrders = increment ? s.activeOrders+1 :s.activeOrders-1
s.lastDateOrder = new Date()
return await s.save()
}catch(e){
throw e
}
}

module.exports = {updateActiveOrders}






node.js sinon chai sinon-chai chai-as-promised






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 14:09







Arthur

















asked Nov 22 '18 at 10:58









ArthurArthur

197




197













  • I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

    – James
    Nov 22 '18 at 11:37











  • Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

    – Arthur
    Nov 22 '18 at 13:12













  • "is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

    – James
    Nov 22 '18 at 14:25








  • 1





    Yes it does, that was the problem :)

    – Arthur
    Nov 23 '18 at 11:48






  • 1





    Possible duplicate of Sinon not stubbing on module.exports

    – James
    Nov 23 '18 at 12:42



















  • I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

    – James
    Nov 22 '18 at 11:37











  • Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

    – Arthur
    Nov 22 '18 at 13:12













  • "is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

    – James
    Nov 22 '18 at 14:25








  • 1





    Yes it does, that was the problem :)

    – Arthur
    Nov 23 '18 at 11:48






  • 1





    Possible duplicate of Sinon not stubbing on module.exports

    – James
    Nov 23 '18 at 12:42

















I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

– James
Nov 22 '18 at 11:37





I'd question whether any of these tests are actually genuinely passing at all, or whether you are getting false positives. You are dealing with promises and I don't think these tests are correctly testing those e.g. expect without should or eventually, as far as I can recall, won't wait for the Promise to resolve. There's not a lot to go on here e.g. what runner you are using? what does spawnOrderJob() look like? Where are dao, strategyModule and helpers defined?

– James
Nov 22 '18 at 11:37













Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

– Arthur
Nov 22 '18 at 13:12







Hey, well is not that the role of chai-as-promised, to resolve the promise itself ? the rejectWith works with other tests, but when i need to test the return values of the promise, i use await/async syntax in my test, but this is not the case here, i just want to check if my functions are called correctly, and changing behavior of the stubbed functions, i've just added the function to test for your information. thx for ur reply, maybe i'm tired, and can't see the evidence :)

– Arthur
Nov 22 '18 at 13:12















"is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

– James
Nov 22 '18 at 14:25







"is not that the role of chai-as-promised, to resolve the promise itself?" - only when you explicitly tell it to via resolves, and the test will only verify correctly if you use the specific promise-related expressions e.g. expect(Promise.resolve(5)).to.equal(5) will always fail, where as expect(Promise.resolve(5)).to.eventually.equal(5) would pass. Regardless, now that I've seen your code I can see why the test fails, and as expected the first tests are false positives as they aren't correctly testing the code.

– James
Nov 22 '18 at 14:25






1




1





Yes it does, that was the problem :)

– Arthur
Nov 23 '18 at 11:48





Yes it does, that was the problem :)

– Arthur
Nov 23 '18 at 11:48




1




1





Possible duplicate of Sinon not stubbing on module.exports

– James
Nov 23 '18 at 12:42





Possible duplicate of Sinon not stubbing on module.exports

– James
Nov 23 '18 at 12:42












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429446%2fstub-never-called-with-sinon-and-nodejs-using-chai-as-promised%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429446%2fstub-never-called-with-sinon-and-nodejs-using-chai-as-promised%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith