jeudi 19 mars 2020

Angular base class for unit tests

Is it possible to use a base class for the unit tests in angular? Because a lot of my imports and declarations are always the same. If i add or replace a class, i always have to change the imports and declarations in every test class.

    beforeEach(async(() => {
    TestBed.configureTestingModule({
        imports: [DialogModule, DynamicDialogModule, FormsModule, TableModule, HttpClientTestingModule, ContextMenuModule],
        declarations: [MyDialog ,OtherDialog],
        providers: [MyService],
    })
        .compileComponents();
}));

The above code ist the code which is mostly the same in every test class, so this is the code that should be in the base class.

Aucun commentaire:

Enregistrer un commentaire