Filter by description on findByLabel for password input tests
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, react
- Lĩnh vực
- frontend, testing-qa
Hướng nghiên cứu
Bắt đầu với các điểm vào truy vấn getByLabelText và findByLabelText, sau đó so sánh hành vi của chúng với việc lọc theo description được mô tả cho getByRole. Kiểm tra cách ví dụ password-input cần được khớp thông qua label của nó và nội dung của aria-describedby. Công việc được xem là hoàn tất khi bộ lọc description được yêu cầu hoạt động với các password inputs có label mà không làm hỏng các truy vấn label hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
I am trying to test that the inputs in my form have correct inline validation errors set as aria descriptions. This works great when the input is simply a textbox:
<Label>
Email
<input type="text' aria-describedby="emailError" />
</Label>
<div id="emailError">Please enter a valid email address</div>
...
expect(findbyRole('textbox', {
name: 'Email',
description: 'Please enter a valid email'
})).toBeInTheDocument();
However, when the input is a password since it has no role I cannot use the description field on getByRole to find the element.
Describe the solution you'd like
This issue recommends using getByLabelText for password inputs, so it would be a lot easier if that query could also search by description.
<Label>
Password
<input type="password' aria-describedby="passwordError" />
</Label>
<div id="passwordError">Please enter your password</div>
...
expect(findByLabelText('Password', {
description: 'Please enter your password'
})).toBeInTheDocument();
Describe alternatives you've considered
Alternatively, if react-testing library could do some magic that means findByRole('password') just works, then that would be a very simple solution and most users probably wouldn't event have to think about it.
For now my tests merely assert that the error exists in the page and ignore the describedby connection.
expect(await screen.findByText('Please enter your new password')).toBeInTheDocument();
Additional context Add any other context or screenshots about the feature
request here.
- Ngôn ngữ chính
- JavaScript
- Star
- 19.7k
- Fork
- 1.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testing-library/react-testing-library
-
fireEvent.select does not wrap its automatic native focus in actCó thể đã có người làm @sergioperezcheco đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict modeCó thể làm lại được @suhailopensource đã nhận 72 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
testing-library/react-testing-library#1466 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
testing-library/react-testing-library#1459 · 2 bình luận ·
-
perf: optimize container lookup with early exitCó thể làm lại được @Ch-Abhinav-Chowdary đã nhận 298 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
testing-library/react-testing-library#1430 · 1 bình luận ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)Có thể đã có người làm @swarnim02 đã nhận 315 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Tất cả issue của testing-library/react-testing-library
Issue tương tự
-
[BUG] Multi-day events show "Ended" while still in progressCó thể đã có người làm @tarunagnihotri534 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
data-umbrella/du-event-board#231 · 2 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NaturalIntelligence/fast-xml-parser#888 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
USACE/chart-docs#766 ·
-
bug callouts regression revealjs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
quarto-dev/quarto-cli#15014 ·
Maintainer thường phản hồi trong vòng 1 ngày