Performance: TestBed configuration
MEDIUM IMPACT
TestBed configuration affects the speed of running Angular unit tests and the responsiveness of test suites during development.
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [CommonModule],
providers: []
}).compileComponents();
});beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AppComponent, UnusedComponent, AnotherUnusedComponent],
imports: [CommonModule, FormsModule, HttpClientModule],
providers: [SomeService]
}).compileComponents();
});| Pattern | Declarations/Imports | Compilation Time | Memory Usage | Verdict |
|---|---|---|---|---|
| Heavy TestBed Setup | Many unused components and modules | High (200-500ms) | High | [X] Bad |
| Minimal TestBed Setup | Only required components and modules | Low (50-150ms) | Low | [OK] Good |