【问题标题】:If 'some-component-tag' is an Angular component and it has 'some-input-var' input, then verify that it is part of this module如果 'some-component-tag' 是一个 Angular 组件并且它有 'some-input-var' 输入,那么验证它是这个模块的一部分
【发布时间】:2016-10-19 15:23:08
【问题描述】:

我正在尝试按照 Angular2 测试文档测试我的 Angular 2 应用程序。我目前正在测试的组件有一个外部模板(我已经用外部模板测试了其他组件,并且测试运行良好),但是每当我尝试使用'.compileComponents'编译它或尝试使用'fixture = 创建一个夹具时TestBed.createComponent(testing-component);',它给了我以下错误:

Uncaught: Can't bind to 'input-variable' since it isn't a known property of 'another-component-tag'.
1. If 'another-component-tag' is an Angular component and it has 'input-variable' input, then verify that it is part of this module.
2. If 'another-component-tag' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.
("

我在我的模板(html 文件)中使用了 ''。但不确定为什么测试运行程序在创建指向我在模板文件中定义的另一个组件标记的夹具时会出错。有人可以告诉我可能是什么问题吗?我已经花了几个小时解决这个问题,但仍然无法解决。

【问题讨论】:

  • 被测组件是否正在使用另一个组件?如果是这样,您是否将其放入声明中?
  • 不敢相信我犯了这么愚蠢的错误!感谢您的建议,我提供了测试组件使用的所有服务,但在声明中错过了该组件。再次感谢!

标签: angular angular2-testing


【解决方案1】:

看起来我没有在规范文件的“提供者”下声明我的测试组件中使用的其他组件。问题解决了!

【讨论】:

    猜你喜欢
    • 2021-11-11
    • 2017-10-11
    • 2021-04-20
    • 2023-03-03
    • 2018-07-08
    • 2021-01-23
    • 2018-07-07
    • 1970-01-01
    • 2020-04-14
    相关资源
    最近更新 更多