У меня есть следующий компонент, который я хочу проверить:
компонент:
constructor(
private countrystore: Store<CountryAppState>,
private docstore: Store<DocumentAppState>,
private formBuilder: FormBuilder,
) {}
ngOnInit() {
this.getCountryState = this.countrystore.select('selecttimaticCountryState');
this.getCountryState.subscribe((state) => {
this.countries = state.response;
});
Файл спецификации:
describe('TravellerInfoComponent', () => {
let component: TravellerInfoComponent;
let fixture: ComponentFixture<TravellerInfoComponent>;
Object.defineProperty(window, "matchMedia", {
value: jest.fn(() => { return { matches: true } })
});
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
BrowserAnimationsModule,
HttpClientModule
],
providers: [
FormsModule
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TravellerInfoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
Прежде чем я смогу написать тест, я получаю следующую ошибку:
![enter image description here](https://i.stack.imgur.com/6iD4A.png)
Я смотрел на похожие ответы, которые предлагают использовать оператор 'of' rxjs для имитации наблюдаемого, другие предлагают использовать технику spyOn. Но я не совсем понимаю, где это должно быть вставлено. Любая помощь для тестирования Noob будет здорово.