Create a gist now

Instantly share code, notes, and snippets.

Embed
Angular TestBed is too long
import { FooService } from './foo.service';
import { TestBed } from '@angular/core/testing';
function itLotOfTime(description: string, itBody: () => void) {
for (let i = 0; i < 1000; i++) {
it(description, itBody);
}
}
describe('FooService by using inject', () => { // Takes ~5 seconds on my machine
itLotOfTime('should be created', () => {
TestBed.configureTestingModule({
providers: [FooService]
});
const service: FooService = TestBed.get(FooService);
expect(service).toBeTruthy();
});
});
describe('FooService by new', () => { // Takes 1.3 seconds on my machine
itLotOfTime('should be created', () => {
expect(new FooService()).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment