userEvent.click(screen.getAll*) produces an ambiguous error
See original GitHub issue@testing-library/dom
version: @testing-library/dom@7.29.4- Testing Framework and version: Karma
- karma@4.4.1
- jasmine@3.3.1
- DOM Environment: Chrome Version 88.0.4324.182 (Official Build) (x86_64)
Relevant code or config
Repro sandbox: https://codesandbox.io/s/react-testing-library-demo-forked-u4lcu?file=/src/__tests__/hello.js
What you did:
I ran a test and tried to click the result of screen.getAllByLabelText
.
What happened:
Running the test produces something like:
where the element in question is an array:
Problem description:
The thrown error is a bit ambiguous – there is room for improvement.
Suggested solution:
I would assume that userEvent
methods would error on having multiple elements – where the error text would be a bit more direct. I am not sure if a user can interact with more than 1 element at a time.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
React Testing Library with userEvent.click wrong act() warning
The workaround to the Warning: It looks like you're using the wrong act() around your test interactions. console error is to add the...
Read more >user-event v13 - Testing Library
Pointer events options. Trying to click an element with pointer-events being set to "none" (i.e. unclickable) will throw an error.
Read more >How To Test a React App with Jest and React Testing Library
error Warning: An update to App inside a test was not wrapped in act(...). When testing, code that causes React state updates should...
Read more >React Testing Library and the “not wrapped in act” Errors
When testing, code that causes React state updates should be wrapped into act(...): act(() => { · // With react-dom/test-utilsit("should render and update...
Read more >React Testing Library Cheatsheet - Codecademy
import { render, screen } from '@testing-library/react' ... The provided userEvent object contains methods that can be used to simulate clicks, typing, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unless someone gets to it by end of Sunday, I’ll probably give it a stab.
@timdeschryver You’re right I wasn’t thinking about it, I just reproduced it with
fireEvent
also. So this should be fixed here…