我正在按照Angular2测试文档测试我的Angular2应用程序。我目前测试的组件有一个外部模板(我已经测试了其他组件与外部模板,有测试运行良好),但每当我尝试使用'.compileComponents'编译它或尝试使用'fixture = TestBed.createComponent(test -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文件)。但不确定为什么测试运行器在创建指向我在模板文件中定义的另一个组件标记的fixture时给出错误。有人能给我提示一下可能是什么问题吗?我已经花了几个小时来解决这个问题,但仍然没有找到解决办法。
看起来我没有在规范文件中的'providers'下声明测试组件中使用的其他组件。问题解决了!