How to stub a imported function in ES6 (using babel6)

524 views
Skip to first unread message

danielma...@gmail.com

unread,
Sep 7, 2016, 8:13:55 AM9/7/16
to Sinon.JS
I'm importing Enter code here...
//Utils file
export default = () => {}

//Other file
import * as Utils from 'lib/utils';
export const foo = () => Utils.default();

//test file
import * as Utils from 'lib/utils';
import * as Foo from 'lib/foo';

it('should call default from utils file', ()=> {
    const myStub = sinon.stub(Utils, 'default');
    Foo.foo();

})

danielma...@gmail.com

unread,
Sep 7, 2016, 6:20:58 PM9/7/16
to Sinon.JS
Sorry, can't edit

    expect(myStub.calledOnce).to.be.true;
})
Reply all
Reply to author
Forward
0 new messages