Lets take the following example:
const listDefinition: any = {
module: "module",
service: "service",
listname: "listname"
};
@Component(...)
class MockTreeExpanderComponent extends TreeExpanderComponent {...}
class MockListConfigurationsService extends ListConfigurationsService {...}
describe('ColumnsListConfigurationsComponent Test cases', () => {
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();
});
});
As you can see, I have a Mock component (MockListViewerGridComponent) and service (ListConfigurationsService), a configuration variable (listDefinition) and the fixture and component that I want to test.
My question is about performance and test memory management:
- The variables instantiated inside of describe method will be destroy as soon as the all tests inside of describe finishes?
- Should I declare all variables and mock classes/services inside of describe?
- Should I create a fixture in
beforeEachorbeforeAll? By doing that, I will have performance improvement?
Thank you!
from Karma + Jamsine (Angular Testing): Where should I define mock classes and test variables
No comments:
Post a Comment