angularverifyts-mockito

ts-mockito verifying not correctly


Hi I am stuck on the tests for longer than i would like to admit. But I need help on my test. I console logged the class I want to test and the code flow I need to be tested. But when i call veryfy on my function that is called, ts-mockito returns that it was not called, even when I have proof it must have been so with my logs.

const someDependency= mock(SomeDependency);    
class= new myService(instance(someDependency));

  test('call the function', fakeAsync(() => {
    class.init();
    tick(1000);
    verify(myService.getLoginPopup(anything())).once();
  }));

And in my class:

console.log('logger: Pos1', );
this.myService.getLoginPopup(someObj, callbackFunc());
console.log('logger: Pos2', );

The problem is I can see the two logs, so if I'm not mistaken it should have to be called right?


Solution

  • I think verify(myService.getLoginPopup(anything())).once(); should be verify(myService.getLoginPopup(anything(), anything())).once(); because you are calling the method with two arguments later.