Skip to content

userEvent.click(screen.getAll*) produces an ambiguous error #892

Closed
@juanca

Description

@juanca
  • @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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions