Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!