简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM