如果'some-component-tag'是一个Angular组件并且它有'some-input-var'输入,那么请验证它是否是该模块的一部分

时间:2016-10-19 15:23:09

标签: angular angular2-testing

我正在尝试按照Angular2测试文档测试我的Angular 2应用程序。我正在测试的组件有一个外部模板(我已经使用外部模板测试了其他组件,并且测试运行正常),但每当我尝试使用'.compileComponents'编译它或尝试使用'fixture =创建一个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文件)中使用''。但是不确定为什么测试运行器在创建指向我在模板文件中定义的另一个组件标签的夹具时发出错误。有人能给我一个关于可能是什么问题的线索吗?我已经花了好几个小时来解决这个问题,但仍然无法提出解决方案。

1 个答案:

答案 0 :(得分:1)

看起来我没有在spec文件中的'providers'下声明我的测试组件中使用的其他组件。问题解决了!