我在尝试执行此测试时遇到错误“ TypeError:尝试还原时无法读取未定义的属性'restore'”。我认为这与测试的异步/等待性质有关,但我不确定为什么这行不通。我也尝试过在这里调用done()回调。我这样做正确吗?
describe('#createObjects()', function () {
let myStub: any;
beforeEach(function () {
myStub = sinon.stub(obj, 'doStuff');
});
afterEach(function () {
myStub.restore();
});
it('should throw correct packaged error on exception', async function () {
// Do some testing
let error = {}; // Some error object
let expected = {} // Some expected error object
myStub.throws(error);
try {
await subject.executeProcess();
} catch (error) {
expect.(error).to.eql(expected);
}
});
});