【发布时间】: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 文件)中使用了 ''。但不确定为什么测试运行程序在创建指向我在模板文件中定义的另一个组件标记的夹具时会出错。有人可以告诉我可能是什么问题吗?我已经花了几个小时解决这个问题,但仍然无法解决。
【问题讨论】:
-
被测组件是否正在使用另一个组件?如果是这样,您是否将其放入声明中?
-
不敢相信我犯了这么愚蠢的错误!感谢您的建议,我提供了测试组件使用的所有服务,但在声明中错过了该组件。再次感谢!