StaticInjectorError(平台:核心)[RegistrationComponent-> ToastrManager]

时间:2019-03-07 14:08:57

标签: unit-testing angular6 karma-jasmine toastr

[由于Toastr Manager,测试组件时出错] [1]

<img src="https://i.stack.imgur.com/hjhd9.png">

我在此组件中未使用Toastr Manager,但仍显示错误。

"Error: StaticInjectorError(DynamicTestModule)[RegistrationComponent -> ToastrManager]: 
  StaticInjectorError(Platform: core)[RegistrationComponent -> ToastrManager]: 
    NullInjectorError: No provider for ToastrManager!"

1 个答案:

答案 0 :(得分:0)

这是因为RegistrationComponent中存在的某些子组件正在使用它。

因此,当您创建RegistrationComponent时,子组件UI也会在测试浏览器中呈现,并且失败。