• 0

Stubbing a class without invoking a constructor


You can create Stub instances using sinon.createStubInstance.
const sinon = require('sinon');
const Foo = require('../Foo.js');
const fooStub = sinon.createStubInstance(Foo);
fooStub.foo {
    bar() {
        returns 'bar';
    }
}

expect(fooStub.foo.bar()).to.equal('bar');