您应该恢复getObj
in after()
功能,请按以下方法尝试。
describe('App Functions', function(){
var mockObj;
before(function () {
mockObj = sinon.stub(testApp, 'getObj', () => {
console.log('this is sinon test 1111');
});
});
after(function () {
testApp.getObj.restore(); // Unwraps the spy
});
it('get results',function(done) {
testApp.getObj();
});
});
describe('App Errors', function(){
var mockObj;
before(function () {
mockObj = sinon.stub(testApp, 'getObj', () => {
console.log('this is sinon test 1111');
});
});
after( function () {
testApp.getObj.restore(); // Unwraps the spy
});
it('throws errors',function(done) {
testApp.getObj();
});
});