Stub out module function

后端 未结 4 1133
粉色の甜心
粉色の甜心 2021-02-13 21:07

Edit: Being a little bit more precise.

I want to test usecases for a Github API wrapper extension, that our team has created. For testing, we don\'t want to use API wrap

4条回答
  •  盖世英雄少女心
    2021-02-13 21:56

    If you are doing

    var github = require('../services/github');

    in global scope, then you can using 'global' as the object and 'github' as the method to be stubbed out.

    var stub_github = sinon.stub(global, "github", function (args, callback) { 
        console.log("the github(...) call was stubbed out!!");
    });
    

提交回复
热议问题