ngrx / store-log-monitor

Log Monitor for @ngrx/store-devtools and Angular
MIT License
63 stars 18 forks source link

Provide testing module for store-log-monitor #16

Closed wesleycho closed 7 years ago

wesleycho commented 7 years ago

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.

brandonroberts commented 7 years ago

Have you tried using the NO_ERRORS_SCHEMA in your test module?

wesleycho commented 7 years ago

How does one use it?

brandonroberts commented 7 years ago

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
    });

    //...

  });
});
wesleycho commented 7 years ago

Oh interesting, thanks!

I wish this was better documented on the Angular side :( .

brandonroberts commented 7 years ago

There is a section in the newly published testing chapter https://angular.io/docs/ts/latest/guide/testing.html#!#shallow-component-test

wesleycho commented 7 years ago

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.