jeudi 21 mars 2019

Do NGRX and NGXS create a separate Store instances when created in a TestBed module?

I want to make sure that using a real Store instance, instead of a mock Store, will not interfere with my existing store data in my Angular app. This may be more of a general question about Angular testing modules but I want to direct it specifically towards state management libraries in this case.

Example test module:

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        NgxsModule.forRoot([ZooState])
      ],
    }).compileComponents();
    store = TestBed.get(Store);
  }));

Example app.module

@NgModule({
  imports: [
    NgxsModule.forRoot([ZooState])
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

Will the TestBed instance interfere with (actually use) the AppModule instance? If so, why would they recommend NOT mocking the store in both sets of documentation?

Aucun commentaire:

Enregistrer un commentaire