I am new to Angular 2 testing. I am trying to figure out what is the difference in using testsbed.get()
and just using inject
at the test level.
eg:
beforeEach(() => {
TestBed.configureTestingModule({
providers: [SomeService]
});
const testbed = getTestBed();
someService= testbed.get(SomeService);
});
});
vs
it('test service', inject([SomeService], (someService: SomeService) => {
inject
callstestbed.get
internally. The main difference is that if you provideAsyncTestCompleter
toinject
it will runcompileComponents
and the object provided has adone
function that completes the execution of an async test. Looks like this is old code and it is preferred to useasync(inject(
instead. Then from this point looks like a syntax preference matter. – Brittnee