Simply running the application I get no error and it works just fine, but when I run my tests I get the following error:
\'pattern-list\' is not a known elem
I think you need
TestBed.configureTestingModule({imports: [AppModule]});
The current approach to avoid these errors when testing components is to make their tests shallow. As per the official docs:
Add NO_ERRORS_SCHEMA to the testing module's schemas metadata to tell the compiler to ignore unrecognized elements and attributes. You no longer have to declare irrelevant components and directives.
So you can simply import NO_ERRORS_SCHEMA
and add it to your testing module config:
import { NO_ERRORS_SCHEMA } from '@angular/core';
TestBed.configureTestingModule({
schemas: [ NO_ERRORS_SCHEMA ]
})
But be aware of:
Shallow component tests with NO_ERRORS_SCHEMA greatly simplify unit testing of complex templates. However, the compiler no longer alerts you to mistakes such as misspelled or misused components and directives.
As micronyks mentined in his answer I need to add my other dependencies in the declarations of configureTestingModule. So if I modify my module configuration in the test like this:
TestBed.configureTestingModule({declarations: [AppComponent,PatternListComponent]});
it'll work. It seems you need to add every dependency in the configureTestingModule declaration.