1. TDD
- 실제 코드를 작성하기 전에 테스트 코드를 먼저 작성
- 테스트 코드를 작성한 후 그 테스트 코드를 Pass 할 수 있는 실제 코드를 작성
- TDD를 하면 좋은 점
- 소스 코드에 안정감이 부여
- TDD를 사용하면 디버깅 시간이 줄어들고 실제 개발 시간 단축
- 소스 코드 하나하나를 신중하게 짤 수 있기 때문에, 클린한 코드가 나올 확률이 높아짐
2. FireEvent API
- 유저가 발생시키는 액션에 대한 테스트를 해야하는 경우 사용
test("When the - button is pressed, the counter changes to -1", () => {
render(<App />);
const buttonElement = screen.getByTestId("minus");
fireEvent.click(buttonElement);
const counterElement = screen.getByTestId("counter");
expect(counterElement).toHaveTextContent(-1);
});