Skip to content

Instantly share code, notes, and snippets.

@mbreton
Last active March 9, 2018 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbreton/80c006a3856d8d13d27369e74c585051 to your computer and use it in GitHub Desktop.
Save mbreton/80c006a3856d8d13d27369e74c585051 to your computer and use it in GitHub Desktop.
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