Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
unit test angular ngrx component

I'm trying to test a unit test for a component into angular, into the component I have a filterTypeahead function that expect a string, this value is inserted into a Subject, when it happen I have other code for dispatch a loadData, so with filteredData$ observable I subscribe to it for get the data

it('should not get the data if there are no input value', fakeAsync(async () => {
    component.ngAfterViewInit();
    component.filterTypeahead({ value: '' });
    tick(500);
    
    component.filteredData$.subscribe((value: any[]) => {
      expect(value).toEqual([]);
    });
  }));

But I don't know why I'm getting the flollow error

TypeError: Cannot read properties of undefined (reading 'data') on selectors

  let component: WidgetComponent;
  let fixture: ComponentFixture<WidgetComponent>;
  let store: MockStore;

  const initialState = {
    data: []
  };


beforeEach((() => {
    TestBed.configureTestingModule({
      declarations: [WidgetComponent],
      schemas: [NO_ERRORS_SCHEMA],
      providers: [
        provideMockStore({ initialState })
      ],
    }).compileComponents();

    store = TestBed.inject(MockStore);
    spyOn(store, 'dispatch');
  }));

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda