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

140
Views
How to test NGXS selectors

Hi I am using NGXS state managment library in my App and I have selector like below and everything is working fine but when I am testing my app I have got error like below. PrintItemsState is lazy loadad. What I noticed problem is that im passing PrintItemsState as argument here.

@Selector([PrintItemsState])

but i have no clue how to fix it. I will be graceful for any suggestions.

enter image description here

print-items.selectors.ts

@Injectable()
export class PrintItemsSelectors { 
...

  @Selector([PrintItemsState])
  static filter(state: PrintItemsStateModel): KeyValue<string, string>[] {
    const filters = state.fabricPage.page.Filter;
    const filterKeys = Object.keys(state.fabricPage.page.Filter);
    const activeFilters = [];
    filterKeys.forEach((key) => {
      if (filters[key]) {
        activeFilters.push({key: [key], value: filters[key]});
      }
    });
    return activeFilters;
  }

...
}

print-items.module.ts

@NgModule({
  declarations: [
    PrintItemsListComponent,
    FabricTableComponent,
    SummaryTableComponent,
    RollCodeDialogComponent,
    CommentDialogComponent
  ],
  imports: [
    PrintItemsRoutingModule,
    SharedModule,
    NgxsModule.forFeature([PrintItemsState])
  ],
  providers: [
    PrintItemsHttpService
  ]
})
export class PrintItemsModule {
}
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Unfortunatelly I still havent`t solved my problem. I have posted question on their github but without answer. I found simillar issue but I am using NGXS 3.7.2 so it shouldnt be a case. Temporary solution is that I moved selectors inside state class.

about 4 years ago · Santiago Gelvez Report
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!