Jest

  1. 쿼리함수
  2. ESLINT PlugIn
  3. TDD 테스트 주도 개발
  4. FireEvent
  5. query 사용 우선순위
  6. MSW 사용해서 테스트하기

목차

어떤 쿼리가 우선적으로 사용되어야 하는가?

<aside> 💡 Queries are the methods that Testing Library gives you to find elements on the page. There are several types of queries ("get", "find", "query"); the difference between them is whether the query will throw an error if no element is found or if it will return a Promise and retry. Depending on what page content you are selecting, different queries may be more or less appropriate. See the priority guide for recommendations on how to make use of semantic queries to test your page in the most accessible way.

</aside>

권장 우선순위 가이드

Queries Accessible to Everyone

<aside> 💡 Queries Accessible to Everyone  Queries that reflect the experience of visual/mouse users as well as those that use assistive technology.

</aside>

getByRole

<aside> 💡 getByRole: This can be used to query every element that is exposed in the accessibility tree. With the name option you can filter the returned elements by their accessible name. This should be your top preference for just about everything. There's not much you can't get with this (if you can't, it's possible your UI is inaccessible). Most often, this will be used with the name option like so: getByRole('button', {name: /submit/i}). Check the list of roles.

</aside>