Skip to content

feature: implement toHaveDisplayValue Jest matcher #1456

Closed
@mdjastrzebski

Description

@mdjastrzebski

Describe the Feature

toHaveDisplayValue is a Jest DOM matcher that asserts the value visible to the user in text inputs.

Adapting it to our case it would assert the value in TextInput host elements, to match given value.

Possible Implementations

Proposed API:

export function toHaveDisplayValue(
  this: jest.MatcherContext,
  element: ReactTestInstance,
  valueToMatch: TextMatch,
  options?: TextMatchOptions
)

The matcher should:

  1. Validate that it is invoked on host TextInput element
  2. Get the current value as props.value ?? props.defaultValue
  3. Compare it with passed valueToMatch.

Each matcher should have a fairly comprehensive test suite.

Links

Related Issues

#1454

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions