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

feat: Improve error message when passing an Array while a single Element is expected #906

Merged
merged 3 commits into from
Mar 7, 2021

Conversation

juanca
Copy link
Contributor

@juanca juanca commented Feb 28, 2021

What: New error message when passing an Array.

Why: This can be a quick typo when using screen.getAll* or screen.queryAll* queries.

How: Type checking for Array.

Checklist:

  • Documentation added to the
    docs site N/A
  • Tests
  • Typescript definitions updated N/A
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 28, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b425e0c:

Sandbox Source
react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Feb 28, 2021

Codecov Report

Merging #906 (b425e0c) into master (f7b5c33) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #906   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines          942       944    +2     
  Branches       284       285    +1     
=========================================
+ Hits           942       944    +2     
Flag Coverage Δ
node-10.14.2 100.00% <100.00%> (ø)
node-12 100.00% <100.00%> (ø)
node-14 100.00% <100.00%> (ø)
node-15 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/helpers.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7b5c33...b425e0c. Read the comment docs.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some minor suggestions.

src/helpers.js Outdated Show resolved Hide resolved
src/helpers.js Outdated Show resolved Hide resolved
@juanca juanca requested a review from eps1lon March 3, 2021 19:53
@juanca
Copy link
Contributor Author

juanca commented Mar 3, 2021

I'm not really sure what went wrong with the validate script. It passes locally. And I do not see a re-run button.

Reading a bit into it, it might be an async failure. I think I've seen a PR about some timer shenanigans, it might be related.

Lemme know how I should proceed.

@MatanBobi
Copy link
Member

MatanBobi commented Mar 7, 2021

I'm not really sure what went wrong with the validate script. It passes locally. And I do not see a re-run button.

Reading a bit into it, it might be an async failure. I think I've seen a PR about some timer shenanigans, it might be related.

Lemme know how I should proceed.

I've just re-ran the jobs but it looks like it's still failing for 10.14.2.
Did you try to reproduce it locally with node 10.14.2? I'm trying to figure out if this only fails in CI for that version or not.

@eps1lon eps1lon changed the title fix: Improve error message when passing an Array (#892) feat: Improve error message when passing an Array (#892) Mar 7, 2021
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks!

@eps1lon eps1lon added the enhancement New feature or request label Mar 7, 2021
@eps1lon eps1lon changed the title feat: Improve error message when passing an Array (#892) feat: Improve error message when passing an Array Mar 7, 2021
@eps1lon eps1lon linked an issue Mar 7, 2021 that may be closed by this pull request
@eps1lon eps1lon changed the title feat: Improve error message when passing an Array feat: Improve error message when passing an Array while a single Element is expected Mar 7, 2021
@eps1lon eps1lon merged commit 300bfe2 into testing-library:master Mar 7, 2021
@github-actions
Copy link

github-actions bot commented Mar 7, 2021

🎉 This PR is included in version 7.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MatanBobi
Copy link
Member

MatanBobi commented Mar 8, 2021

Nice work, thanks!

@eps1lon I see that it passed in CI, did you just re-run it?

@eps1lon
Copy link
Member

eps1lon commented Mar 8, 2021

@eps1lon I see that it passed in CI, did you just re-run it?

Yep, it's a flaky test. Seems like others have the same problem: #901 (comment).

@MatanBobi
Copy link
Member

@eps1lon I see that it passed in CI, did you just re-run it?

Yep, it's a flaky test. Seems like others have the same problem: #901 (comment).

Cool, thanks for the update :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

userEvent.click(screen.getAll*) produces an ambiguous error
3 participants