0
votes

I am trying to stub out a module and the return inside of it and having a little trouble. Here is what I have

var CrowdControlGet = sinon.stub();
var CrowdControl = sinon.stub().returns({
    get: CrowdControlGet
});

this does not seem to work, but when I just have

  var CrowdControl = testHelpers.stub()

it works fine, how do i get it to return a get inside which is also a stub? Thanks!

1

1 Answers

1
votes

Have you tried like this:

var CrowdControlGet = sinon.stub();
sinon.stub(CrowdControl, function () {
  return {
    get: CrowdControlGet // or just sinon.stub()
  }
});