I created an Angular application under 4. I have migrated from version to version and am currently latest version 9. I was reviewing my tests. I have a Login component th
You can also create a mocked class to be used as your UserService:
class MockUserService {
myMethod(): void {
// mocked logic
}
}
describe('LoginComponent', () => {
...
providers: [
...
{ provide: UserService, useClass: MockUserService }
]
...
});
providers: [
...
{ provide: UserService, useClass: userServiceSpy }
]
Should be changed to:
providers: [
...
{ provide: UserService, useValue: userServiceSpy }
]