ByText[Testing Library]

SnowCat·2023년 3월 6일
0

Testing Library

목록 보기
4/11
post-thumbnail
getByText(
  container?: HTMLElement,
  text: TextMatch,
  options?: {
    selector?: string = '*',
    exact?: boolean = true,
    ignore?: string|boolean = 'script, style',
    normalizer?: NormalizerFn,
  }): HTMLElement

//test
const aboutAnchorNode = screen.getByText(/about/i)
  • text node가 있는 모든 element의 텍스트를 검사하는 메서드

Options

  • ignore: 스크립트, 스타일 태그에 같은 값이 있을 때에 이를 반환하지 않도록 하는 옵션

출처:
https://testing-library.com/docs/queries/bytext

profile
냐아아아아아아아아앙

0개의 댓글