Angular 4.x: No provider for Service

Your test for ContactService uses a testing module which only declares ContactService as provider. But ContactService needs a SkillsService. So SkillsService must also be part of the providers of the testing module:

TestBed.configureTestingModule({
  providers: [ContactService, SkillsService]
});

You could also use the whole application module in your test:

TestBed.configureTestingModule({
  imports: [AppModule]
});

But I wouldn't recommend that because your tests will become slower and slower while the application grows.

Share:
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin about 2 months

Related