Closed wesleycho closed 7 years ago
Have you tried using the NO_ERRORS_SCHEMA in your test module?
How does one use it?
You add it to the schemas
array in your testing module.
import {NO_ERRORS_SCHEMA} from '@angular/core';
describe('Component', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ Component ], // declare the test component
schemas: [ NO_ERRORS_SCHEMA ] // ignores unknown elements
});
//...
});
});
Oh interesting, thanks!
I wish this was better documented on the Angular side :( .
There is a section in the newly published testing chapter https://angular.io/docs/ts/latest/guide/testing.html#!#shallow-component-test
One thing we have come upon at work is that if we use the store log monitor, when one wants to test that component, one must provide a component with the selector
ngrx-store-log-monitor
, which interferes with tslint if you add codelyzer and usecomponent-selector-prefix
.This library should provide a mechanism for this situation to provide a mock component so that Angular doesn't throw when trying to compile a component in the template that it doesn't recognize.