When i run the unit testing in angular 8 project, i found an error in ngx-toastr
NullInjectorError: StaticInjectorError(DynamicTestModule)[ToastrService -> InjectionToken ToastConfig]:
And i imported the requierd modules in the spec.ts file, And also i declared forRoot() in app.module.ts
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MatTabsModule,
ReactiveFormsModule,
MatTooltipModule,
HttpClientTestingModule,
RouterTestingModule,
ToastrModule
],
declarations: [CommunicationComponent],
providers: [
ToastrService,
]
})
.compileComponents();
}));
import { ToastrModule } from 'ngx-toastr';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ToastrModule.forRoot()],
})
.compileComponents();
}));
Add ToastrModule.forRoot() in imports as shown above and your error might be resolved