Обнаружение проблемы с тестированием `ngOnDestroy` с помощью` @testing-library`
Вот мои объявления компонентов:
ngUnsubscribe: Subject<any> = new Subject();
....
ngOnDestroy() {
if (this.ngUnsubscribe) {
this.ngUnsubscribe.next(true);
this.ngUnsubscribe.unsubscribe();
}
}
связывание, чтобы проверить ngOnDestroy
в спецификации:
describe('setup and config testing goes here', () => {
const removeSubscription = jest.fn();
test('component instance created', async () => {
const component = await render(SetupConfigComponent, {
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
imports: [
RouterModule.forRoot([]),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (customTransLoader),
deps: [Store]
},
isolate: true
})
],
componentProperties: {
headerNaviLinksCode: [],
footerNaviLinksCode : [],
footerNaviLinks: [],
headerNaviLinks: [],
selectedCurrLang: '',
hideComponent: true,
title: '',
successResponse: {},
responseClass: {},
headingparam: {},
routingList: [],
currentLang: '',
shouldFadeOut: true,
ngUnsubscribe: {
ngUnsubscribe: removeSubscription
} as any
},
providers: [
provideMockStore({}),
{
provide: ActivatedRoute
},
{
provide: { 'events': () => {} }
},
{
provide: {'translate':TranslateService}
},
{
provide: LangDataService
},
{
provide: APP_BASE_HREF, useValue: '/'
}
]
});
const instace = component.fixture.componentInstance;
instace.ngOnDestroy();
expect(removeSubscription).toHaveBeenCalledTimes(1);
})
})
Но появляется сообщение об ошибке:
TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
Как это исправить? в чем именно здесь проблема? любая помощь?