Last active
March 9, 2018 18:20
-
-
Save mbreton/80c006a3856d8d13d27369e74c585051 to your computer and use it in GitHub Desktop.
Angular TestBed is too long
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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