Is Not a Known Element Angular Test

angular typescript

Recently, I have added some tests to my project and ran npm run test and got this error:

Error: Template parse errors:
'app-component' is not a known element:
1. If 'app-component' is an Angular component, then verify that it is part of this module.
2. If 'app-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<div>
  [ERROR ->]<app-component></app-component>

This error means that you have Non-Angular elements and trying to test them. You need to go spec.ts file (with this error ) and add CUSTOM_ELEMENTS_SCHEMA to your test module:

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

describe('Component', () => {
  let component: Component;
  let fixture: ComponentFixture<Component>;

  beforeEach(async(() => {
      declarations: [ Component ],
comments powered by Disqus