Closed
Description
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:
- Validate that it is invoked on host TextInput element
- Get the current value as
props.value ?? props.defaultValue
- Compare it with passed
valueToMatch
.
Each matcher should have a fairly comprehensive test suite.
Links
toHaveDisplayValue
matcher code from Jest DOM: https://github.com/testing-library/jest-dom/blob/main/src/to-have-display-value.js