eatthefrog

리엑트 테스트 코드 시작하기 본문

프론트엔드 노트

리엑트 테스트 코드 시작하기

eater_forg 2025. 12. 2. 14:22

<종류>

  1. Manual Testing : Error-prone: It’s hard to test all posiible combiniations and scenarios
  2. Automated Testing: Very techinincal but allows you to test ALL building blocks at once

 

<Automated Testing: 종류>

  1. 유닛 테스트: The most common / important kind of test
    • Test the inidivisual building blocks (funtions, components) in isolation
    • Projects typically contain doaens or hundereds of unit testes
  2. 통합 테스트: Also imporant, but focus on unit tests in most cases
    • Test the combiniation of multiple building blocks
    • Projects typically contain a couple of integratin tests
  3. E2E 테스트: Imporant but can also be done maunually (partically)
    • Test complete scenarios in you app as the user would expericnce them
    • Procets typically contain only a few e2e thests

 

<무엇을 테스트할까요?>

  1. 무엇을?
    • Test the different building blocks
    • Unit TestsL The smallest building blocks that make up you app
  2. 어떻게?
    • Test sucess and error cases, also test rare (but posiible) results

 

<추가적인 도구와 설정>

  1. We need a tool for running our tests and asserting the results (Jest)
  2. We need a tool for “simulating” (rendring) our React app / components (React Testing Library)
  3. //package.json "@testing-libarary/jest-dom" : "^5.11.6", "@testing-library/react": "^11.2.2", "@testing-library/user-event": ^12.5.0"