cnunciato / ng-mock-component

An Angular module for mocking components.
MIT License
53 stars 13 forks source link

component selectow used twice #9

Open Pradins opened 7 years ago

Pradins commented 7 years ago

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.

ChrisPanthera commented 6 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' })