marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
810 stars 56 forks source link

Observable.of mock interface implementation #101

Closed ZsZs closed 1 year ago

ZsZs commented 1 year ago

Hi,

By writing complex mocks I realized, that an Observable.of mock interface implementation doesn't fire. The following test fail with timeout, cause the Observable never fires.

import { mock } from 'jest-mock-extended';
import { of } from 'rxjs';

interface TestInterface {
  dummyProperty: string;
}

describe( 'Test Observable.of mock interface implementation', () => {
  it( 'test Observable of an Interface mock', (done) => {
    const mockTestInterface = mock<TestInterface>();

    of( mockTestInterface ).subscribe( testObject => {
      expect( testObject ).toBeTruthy();
      done();
    })
  })
})

What I'm doing wrong, or overseeing?

mrdulin commented 1 year ago

See https://github.com/marchaos/jest-mock-extended/issues/51

ZsZs commented 1 year ago

@mrdulin, thank you for your quick response. I had to make the ignorePropes to an Array, but then it compiles and works.

  beforeAll( () => {
    JestMockExtended.configure({ ignoreProps: ['schedule '] });
  });