Provide testing module for store-log-monitor
wesleycho opened this issue · comments
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 use component-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.
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
When I did a Google search, I first landed on this page & found the original PR implementing it, but neither really gives a clear indication of its usage.
Maybe I need to change my approach with how I search for ng2 stuff, but that's a personal problem.