Open Pradins opened 7 years ago
@Pradins I ran into the same issue and realised I was including the class in 'declarations' as well as the mock class so it was being duplicated i.e. ClassToBeMocked, MockComponent({ selector: 'app-class-to-be-mocked' })
When setting the MockComponent selector (same as the original component) karma throws the following error:
Failed: Template parse errors: More than one component matched on this element. Make sure that only one component's selector can match a given element.
here is how i mock the component:
beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ AppComponent, MockComponent({ selector: 'snackbar' }) ], imports: [], providers: [] }).compileComponents(); }));
imports and providers omitted.