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

docs: getByTestId doesn't work #525

Merged
merged 1 commit into from Dec 22, 2020
Merged

Conversation

DaleSeo
Copy link
Contributor

@DaleSeo DaleSeo commented Dec 19, 2020

What:

Hi, it's me again! I also noticed that the second example test code in READE.md doesn't work.

   double click (24 ms)

   double click

    TestingLibraryElementError: Unable to find an element by: [data-testid="checkbox"]

    <body>
      <div>
        <input
          id="checkbox"
          type="checkbox"
        />
      </div>
    </body>

       8 |   const onChange = jest.fn();
       9 |   render(<input type="checkbox" id="checkbox" onChange={onChange} />);
    > 10 |   const checkbox = screen.getByTestId("checkbox");
         |                           ^
      11 |   userEvent.dblClick(checkbox);
      12 | 

To fix this, we can add a data-testid attribute to the input element but I thought it would be better to query by role because it only renders a single checkbox.

Checklist:

  • Documentation
  • Tests N/A
  • Typings N/A
  • Ready to be merged N/A

@DaleSeo DaleSeo changed the title getByTestId doesn't work docs: getByTestId doesn't work Dec 19, 2020
@codecov
Copy link

codecov bot commented Dec 19, 2020

Codecov Report

Merging #525 (2400bdd) into master (d9b3e4e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #525   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          675       675           
  Branches       211       211           
=========================================
  Hits           675       675           

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 d9b3e4e...2400bdd. Read the comment docs.

@nickmccurdy nickmccurdy merged commit f1ccaad into testing-library:master Dec 22, 2020
@nickmccurdy
Copy link
Member

@all-contributors add @DaleSeo for docs

@allcontributors
Copy link
Contributor

@nickmccurdy

I've put up a pull request to add @DaleSeo! 🎉

@github-actions
Copy link

🎉 This PR is included in version 12.6.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

3 participants