0
Sinon으로 인스턴스화 할 때 생성자가 메서드를 호출하도록하고 싶습니다. 그러나이 함수가 작동하지 않는 것 같습니다. 올바른 인스턴스 :Sinon 메서드를 호출하는 테스트 생성자
class Test {
constructor() {
this.someFunction();
}
someFunction() {
return 1;
}
}
... 시험
describe('constructor',() => {
it('should call someFunction()',() => {
const spyFunc = new Spy(new Test(), 'someFunction');
expect(spyFunc.calledOnce).to.be.true;
});
});
그건 의미가 있습니다 ... 나는 그것에 대해 생각해 봤어야합니다. – Detuned