question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

image

where the element in question is an array:

image

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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
juancacommented, Feb 19, 2021

Unless someone gets to it by end of Sunday, I’ll probably give it a stab.

2reactions
MatanBobicommented, Feb 18, 2021

Isn’t this also the case with fireEvent? If we fix it there, it will also be fixed for user-event because they use fireEvent?

@timdeschryver You’re right I wasn’t thinking about it, I just reproduced it with fireEvent also. So this should be fixed here…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found