-2

'app-footer' is not a known element: 1. If 'app-footer' is an Angular component, then verify that it is part of this module. 2. If 'app-footer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. Need help to fix it. I referenced many document but still not clear.

angular cli-1.7.4 Angular: 5.2.11

Thank you in Advance XXX

Anuradha Gunasekara
  • 6,553
  • 2
  • 27
  • 37
dev
  • 403
  • 2
  • 5
  • 11

1 Answers1

4

When you test a component there might be child components on it's template. If you are not testing the interaction between those components you can ignore the child components in the template. For that you have to import NO_ERRORS_SCHEMA from @angular/core like this.

import { NO_ERRORS_SCHEMA } from '@angular/core';

Then you should add it to the test bed configurations like this.

TestBed.configureTestingModule({
        declarations: [YourComponent],
        providers: [],
        schemas: [NO_ERRORS_SCHEMA]
      }).compileComponents();

Now your test should work.

And if you want to test the child components also. You have to follow a different approach.

Anuradha Gunasekara
  • 6,553
  • 2
  • 27
  • 37