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

139
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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