Skip to content

MatInputHarness.getName() fails with MatInput and ngModel #18624

Closed
@bampakoa

Description

@bampakoa

Reproduction

I am trying to get the name of a MatInput control which is bound to a component property name as:
<input matInput [name]="name" [(ngModel)]="model">

I am using the getName() method of MatInputHarness as:

const input = await loader.getHarness(MatInputHarness);
expect(await input.getName()).not.toBe('')

but the expectation fails. If I remove the ngModel directive, the test passes successfully.

https://stackblitz.com/edit/components-issue-atwks1

Expected Behavior

The test should pass

Actual Behavior

The test fails

Environment

  • Angular: 9.0.2
  • CDK/Material: 9.1.0
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/input

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions