getByText, queryByText, findByText, getAllByText, queryAllByText, findAllByText

API

getByText(
  // If you're using `screen`, then skip the container argument:
  container: HTMLElement,
  text: TextMatch,
  options?: {
    selector?: string = '*',
    exact?: boolean = true,
    ignore?: string|boolean = 'script, style',
    normalizer?: NormalizerFn,
  }): HTMLElement

// example
screen.getByText('ok!');

설명

주어진 TextMatch와 일치하는 textContent가 있는 텍스트 노드가 있는 모든 요소를 검색합니다.

단일 요소가 예상된다면 *ByText, 복수 요소가 예상된다면 *AllByText

<a href="/about">About ℹ️</a>

ByText | Testing Library