On Angular's website, we can see two ways to write unit test of Service.
The first is to instantiate the service by new Service.
let service: ValueService; beforeEach(() => { service = new ValueService(); });
Second, is instantiate the service by TestBed.
beforeEach(() => {
TestBed.configureTestingModule({ providers: [ValueService] });
service = TestBed.inject(ValueService);
});
Can anybody tell me what's the difference between these two methods, when should and should not use each of them, thanks a lot!