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

Use custom testIdAttribute in getSuggestedQuery #651

Merged

Conversation

geoffharcourt
Copy link
Contributor

@geoffharcourt geoffharcourt commented Jun 16, 2020

What:

Currently getSuggestedQuery always uses data-testid to find relevant
elements. This change updates it to use the configured testIdAttribute
if one has been set in the configuration. (Thanks to @smeijer for
pointing me in the right direction for a solution.)

Why:

If a user has set testIdAttribute suggestions will run getByTestId against the wrong elements.

How:

There's a new test to verify this behavior and a small change to the suggestions code.

Checklist:

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

This does not appear to solve #643 yet, but it's a first step in narrowing down the possible cause.

@codesandbox-ci
Copy link

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 35705da:

Sandbox Source
gifted-hoover-fuc9w Configuration

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 16, 2020

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 ddc8dd4:

Sandbox Source
charming-pascal-zrlif Configuration

@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #651 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #651   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines          575       575           
  Branches       145       145           
=========================================
  Hits           575       575           
Impacted Files Coverage Δ
src/suggestions.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 df57d7b...ddc8dd4. Read the comment docs.

Currently `getSuggestedQuery` always uses `data-testid` to find relevant
elements. This change updates it to use the configured `testIdAttribute`
if one has been set in the configuration.
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Super 👍 thanks!

@kentcdodds kentcdodds merged commit 2c19f4f into testing-library:master Jun 16, 2020
@kentcdodds
Copy link
Member

🎉 This PR is included in version 7.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants