【问题标题】:'ngx-bootstrap-treeview' is not a known element in Component Test'ngx-bootstrap-treeview' 不是组件测试中的已知元素
【发布时间】:2021-07-06 08:29:45
【问题描述】:

我已经实现了ngx-bootstrap-treeview,它作为一个功能运行良好,但是当我执行我的组件测试来验证 UI 时,它开始抛出错误。

我已经在app.module.ts中声明了模块

import { NgxBootstrapTreeviewModule } from 'ngx-bootstrap-treeview';
imports: [..., NgxBootstrapTreeviewModule],
exports: [..., NgxBootstrapTreeviewModule]

如果我在我的测试组件abc.component.steps.ts 中导入相同的模块,那么它会开始抛出新的错误:

图书馆链接:https://github.com/Zokelion/ngx-bootstrap-treeview

【问题讨论】:

  • 除了app.module还有其他模块吗?
  • 是的。 Shared.module 但它已经在 app.module 中导入,并且我以类似的方式导入了其他模块并且工作正常。我已经导入 RouterTestingModule 然后我开始面临错误root of undefined

标签: angular routes cucumber karma-jasmine


【解决方案1】:

我可以通过在我的测试用例文件abc.component.steps.ts 中导入以下依赖项来解决它。

RouterTestingModule,
NgxBootstrapTreeviewModule,
BrowserAnimationsModule

希望对大家有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 2022-06-10
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多