小编tam*_*n s的帖子

NullInjectorError: StaticInjectorError(DynamicTestModule)[ToastrService -> InjectionToken ToastConfig]: 在 tslint angular 8

当我在 angular 8 项目中运行单元测试时,我在 ngx-toastr 中发现了一个错误

NullInjectorError: StaticInjectorError(DynamicTestModule)[ToastrService -> InjectionToken ToastConfig]:

我在spec.ts文件中导入了requierd模块,并且我还在app.module.ts中声明了forRoot()

  beforeEach(async(() => {
TestBed.configureTestingModule({
  imports: [MatTabsModule,
    ReactiveFormsModule,
    MatTooltipModule,
    HttpClientTestingModule,
    RouterTestingModule,
    ToastrModule
  ],
  declarations: [CommunicationComponent],
  providers: [
    ToastrService,
  ]
})
  .compileComponents();
Run Code Online (Sandbox Code Playgroud)

}));

unit-testing eslint angular ngx-toastr

8
推荐指数
1
解决办法
9620
查看次数

标签 统计

angular ×1

eslint ×1

ngx-toastr ×1

unit-testing ×1