I'd like to ensure that the constructor is calling a method when instantiated with Sinon, however, I can't seem to get this to work, as I believe the sinon is not watching the correct instantiation:
class Test {
constructor() {
this.someFunction();
}
someFunction() {
return 1;
}
}
... and the test
describe('constructor', () => {
it('should call someFunction()', () => {
const spyFunc = new Spy(new Test(), 'someFunction');
expect(spyFunc.calledOnce).to.be.true;
});
});
Aucun commentaire:
Enregistrer un commentaire