Skip to content
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

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

Closed
juanca opened this issue Feb 17, 2021 · 6 comments · Fixed by #906
Closed

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

juanca opened this issue Feb 17, 2021 · 6 comments · Fixed by #906

Comments

@juanca
Copy link
Contributor

juanca commented Feb 17, 2021

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

@timdeschryver
Copy link
Member

Seems like a good idea to me 👍

@MatanBobi
Copy link
Member

MatanBobi commented Feb 18, 2021

Thanks @juanca for taking the time to open this! :)
Sounds good to me also.. Though I'm thinking the code for this should be inside user-event and not dom-testing-library..
Do you agree so I'll move this one to user-event's repo?

@timdeschryver
Copy link
Member

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?

@MatanBobi
Copy link
Member

MatanBobi commented 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..

@juanca
Copy link
Contributor Author

juanca commented Feb 19, 2021

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

juanca added a commit to juanca/dom-testing-library that referenced this issue Feb 28, 2021
@juanca
Copy link
Contributor Author

juanca commented Feb 28, 2021

I never did specify which Sunday. Lemme know how that looks, it seemed suspiciously too straight-forward ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants