Skip to content

Commit f10d767

Browse files
committed
LoginPage의 input[type=password] 테스트 macher를 변경합니다
input[type=password]의 경우 role을 가지고있지 않음 테스트할 때는 getByLabelText를 권장한다. 관련 토론: - 암호에 role이 없는 이유애 대한 토론 내용도 나온다. testing-library/dom-testing-library#567
1 parent 8c9ca23 commit f10d767

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/LoginPage.test.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { MemoryRouter } from 'react-router-dom';
2-
31
import { render } from '@testing-library/react';
42

53
import LoginPage from './LoginPage';
@@ -16,11 +14,10 @@ describe('LoginPage', () => {
1614
});
1715

1816
it('아이디와 비밀번호를 입력할 수 있는 input과 버튼이 있다.', () => {
19-
const { getByRole, getAllByRole } = renderLoginPage();
17+
const { getByRole, getByLabelText } = renderLoginPage();
2018

21-
expect(getAllByRole('textbox')).toHaveLength(2);
2219
expect(getByRole('textbox', { name: 'E-mail' })).toBeInTheDocument();
23-
expect(getByRole('textbox', { name: 'Password' })).toBeInTheDocument();
20+
expect(getByLabelText('Password')).toBeInTheDocument();
2421
expect(getByRole('button', { name: 'Log in' })).toBeInTheDocument();
2522
});
2623
});

0 commit comments

Comments
 (0)