🎯 테스트 코드 작성 시 Tip
- 테스트 코드를 3가지 관점으로 작성하면 쉽게 작성할 수 있다.
📝 Three “A”s
| test("renders Changed! if the button was clicked", () => { |
| |
| render(<Greeting />); |
| |
| |
| const buttonElement = screen.getByRole("button"); |
| userEvent.click(buttonElement); |
| |
| |
| const outputElement = screen.getByText("Changed!"); |
| expect(outputElement).toBeInTheDocument(); |
| }); |
Arrange
: 테스트 데이터와 테스트 조건 및 환경 설정을 준비
Act
: 테스트해야 하는 로직 실행
Assets
: 예상한 결과와 실행 결과를 비교
댓글을 사용할 수 없습니다.