Tags

, ,

Testcase:

methodToBeTested() {
  const obj = new MyType();
  obj.do();
}

Test:

it('test', () => {
  spyOn(MyType.prototype, 'do');
});

This setup does not let the do method run. In case we cannot spy a function directly through the object, we can spy “the type”.