UI테스트
특정 DOM 요소 취득하기
import { render, screen } from '@testing-library/react'
import { Form } from './Form'
test('이름을 표시한다.', () => {
render(<Form name='bom'/>)
expect(screen.getByText('bom')).toBeInTheDocument()
})특정 DOM 요소를 역할로 취득하기
test('버튼 표시', () => {
render(<Form name='bom'/>)
expect(screen.getByRole('button')).toBeInTheDoucment()
})
test('헤딩 찾기', () => {
render(<Form name='bom'/>)
expect(scrren.getByRole('heading')).toHaveTextContent('계정 정보')
})이벤트 핸들러 호출
매처
Last updated