getByDisplayValue(
container?: HTMLElement,
value: TextMatch,
options?: {
exact?: boolean = true,
normalizer?: NormalizerFn,
}): HTMLElement
<input type="text" id="lastName" />
document.getElementById('lastName').value = 'Norris'
<textarea id="messageTextArea" />
document.getElementById('messageTextArea').value = 'Hello World'
<select>
<option value="">State</option>
<option value="AL">Alabama</option>
<option selected value="AK">Alaska</option>
<option value="AZ">Arizona</option>
</select>
import {render, screen} from '@testing-library/react'
const lastNameInput = screen.getByDisplayValue('Norris')
const messageTextArea = screen.getByDisplayValue('Hello World')
const selectElement = screen.getByDisplayValue('Alaska')
- input, textarea, select element에서 실제 표시되는 값과 일치되는 엘리먼트를 반환하는 메서드
출처:
https://testing-library.com/docs/queries/bydisplayvalue