Search code examples
angularangular2-testing

If 'some-component-tag' is an Angular component and it has 'some-input-var' input, then verify that it is part of this module


I'm trying to test my Angular 2 application, following the Angular2 testing doc. The component I'm currently testing has an external template (I have tested other components with external templates, and there tests run fine), but whenever I try to compile it using '.compileComponents' or try to create a fixture using 'fixture = TestBed.createComponent(testing-component);', it gives me the following error:

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.
("

I'm using '' in my template (html file). But not sure why the test runner is giving an error while creating a fixture pointing to the another component tag I have defined in the template file. Can somebody give me a clue about what might be the issue? I have already spent hours in trouble-shooting this, but still couldn't come up with a work around.


Solution

  • Looks like I did not declare the other component being used in my testing component under 'providers' in the spec file. Problem solved!