我有一个调用API调用的函数,我可以将API调用存根,但是当我 编写单元测试用例并运行伊斯坦布尔报告我看不到测试范围 对于是否满足条件
class EmpController {
getEmployee() {
const options = paylod();
let emp = new Promise((resolve, reject) => {
Service.myAPI(options, (response) => {
if (response.error) {
reject(response.error);
} else {
resolve(response.body);
}
})
});
return emp;
}
}
it('Emp test', (done) => {
// Mock the request response
nock('http://domain')
.post('api/abc')
.reply(201, response);
sinon.stub(outhController, 'getEmployee').returns(Promise.resolve(response));
EmpController.getEmployee(payload)
.then(response => {
//expect an object back
expect(typeof response).to.equal('object');
done();
});
});