New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to test with DateRangePicker #2238
Comments
We recommend testing with enzyme, but in particular, no testing solution's event simulations (enzyme and RTL included) are actually true matches of browser behavior - they just invoke props - so they're not very useful. The click you want doesn't go on the picker directly, it goes on one of the smaller elements contained within it. |
@ljharb Thanks for the answer. |
Understood, but I'm trying to convey that "simulating user interaction" with either RTL or with enzyme doesn't actually give you value, even if it seems to "work", because it doesn't actually match user interaction. At any rate, the issue at hand is likely that your |
I got the elements for the start and end date through the getByRole method. Note below: const firstDate = screen.getByRole('button', {
name: /choose terça-feira, 1 de agosto de 2023 as your check-in date. it’s available./i,
});
const lastDate = screen.getByRole('button', {
name: /choose terça-feira, 22 de agosto de 2023 as your check-in date. it’s available./i,
}); |
Sounds like an issue with RTL then; i'm not sure how getByRole works. |
https://github.com/xereda/datepicker-test In this repository I managed to reproduce the problem. |
getByRoleThe getByRole method from the Testing Library provides a way to select an element by its accessible role. This query is recommended because it encourages developers to write tests that rely on the accessibility information of elements, which ultimately leads to more accessible applications. |
src/components/Datepicker/Datepicker.test.js https://github.com/xereda/datepicker-test/blob/main/src/components/Datepicker/Datepicker.test.js
Note that the modal is closed on the first click. |
react-dates version
21.8.0
Describe the bug
I use the "DateRangePicker" component in a project and I need to test the user flow with the Testing Library. The problem is that when I do the first click (userEvent.click()), on the first date, the modal is closed, not waiting for the selection of the second date.
Source code (including props configuration)
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: