Skip to content

Conflicting components: MatFormField,MatFormField while Testing with Angular 8 #18425

@ignaciojvig

Description

@ignaciojvig

Reproduction

Steps to reproduce:

  1. Import "MatSelectModule" in my-component.spec.ts
  2. Run "npm run test"

Expected Behavior

Jest running my tests as expected

Actual Behavior

An error is thrown, with the current message:

Template parse errors:
More than one component matched on this element. Make sure that only one component's selector can match a given element. Conflicting components: MatFormField,MatFormField
with-mat-select-module

If I remove 'MatSelectModule', I got another error:

Template parse errors:
'mat-select' is not a known element:

  1. If 'mat-select' is an Angular component, then verify that it is part of this module. 2. If 'mat-select' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    without-mat-select-module

Environment

  • Angular: ~8.2.14
  • CDK/Material: ^8.2.3
  • Browser(s): Chrome 80.0.3987.87
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    cannot reproduceThe team is unable to reproduce this issue with the information provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions