Consider the scenario below:
const listDefinition: any = {
module: "module",
service: "service",
listname: "listname"
};
@Component(...)
class MockTreeExpanderComponent extends TreeExpanderComponent {...}
class MockListConfigurationsService extends ListConfigurationsService {...}
describe('ColumnsListConfigurationsComponent Testing', () => {
let fixture: ComponentFixture<ColumnsListConfigurationsComponent>;
let component: ColumnsListConfigurationsComponent;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
ComponentToTest,
MockTreeExpanderComponent
],
providers: [
{ provide: TreeListConfigurationService, useClass: MockTreeListConfigurationService }
]
});
fixture = TestBed.createComponent(ComponentToTest);
component = fixture.componentInstance;
component.listDefinition = listDefinition;
fixture.detectChanges();
});
});
In this setup, I have specific mock components (e.g. MockListViewerGridComponent
) and services (e.g. ListConfigurationsService
), a configuration variable named listDefinition
, and the fixture and component that require testing.
Now, my query pertains to performance
and test memory management
:
- Will the variables created within the describe method be automatically removed once all tests inside it are completed?
- Is it advisable to define all variables and mock classes/services within the describe block?
- In terms of performance enhancement, should I instantiate a fixture in
beforeEach
orbeforeAll
?
Your insights are appreciated!