Angular - Services and Dependency Injection
Given this Angular test setup, what will be the output of
component.getData() if mockService.getData() returns 'test data'?
const mockService = { getData: () => 'test data' };
beforeEach(() => {
TestBed.configureTestingModule({
providers: [{ provide: RealService, useValue: mockService }]
});
component = TestBed.inject(MyComponent);
});
// In component:
getData() {
return this.realService.getData();
}