NagRock / ts-mockito

Mocking library for TypeScript
MIT License
969 stars 93 forks source link

Verify on interface mock does not work (2.6.1) #206

Open distante opened 3 years ago

distante commented 3 years ago

I have this interface mock on my before each test

    SplashScreenMock = mock<SplashScreenPlugin>();
    when(SplashScreenMock.hide()).thenResolve();

when I try to check if it was called using verify(SplashScreenMock.hide()).once() I always says it never was called.

My workaround is to manually create a partial mock instead

SplashScreenMock = {
      hide: jest.fn()
    } as any;

and test it with expect(SplashScreenMock.hide).toHaveBeenCalledTimes(1); (which works just fine)

The code is implemented in this way

    this.globalEvents.homePageFinishLoading$.pipe(first()).subscribe(async () => {
      await this.splashScreen.hide();
      this.logger.log('hideSplashScreen Done');
    });