Got TestingLibraryElementError when running tests
See original GitHub issueHi,
I am trying to test react-select
with this library, and I was following documentation, I got TestingLibraryElementError: Found a label with the text of: Food, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.
Here is my code for the test, it is copied directly from documentation. https://github.com/JLFullstack/react-select-testing/blob/master/src/openMenu.test.js
Here is the repository I set up to re-produce this issue. https://github.com/JLFullstack/react-select-testing
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
React Jest testing : TestingLibraryElementError: Unable to find ...
I am new to react testing. I want to test this component and get back for example the h3 text what was given...
Read more >Common mistakes with React Testing Library - Kent C. Dodds
Hi there I created React Testing Library because I wasn't satisfied with the testing landscape at the time. It expanded to DOM Testing...
Read more >Error: Unable to find an element with text: "My text", while that ...
Describe the bug getByText can find element if text render component with text as not children (See "Steps to Reproduce" below) -const Trans ......
Read more >Improving React Testing Library tests | Alex Khomenko
When running the test we get an error: TestingLibraryElementError: Unable to find an accessible element with the role "textbox" and name ...
Read more >Testing Visible Text with React Testing Library's getByText ...
Testing Library's ByText methods allow us search the DOM for matching text. We do that here to confirm the total amount is displayed ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the confusion @JLFullstack !
That was an issue with the docs 😞
I updated the example here: https://github.com/romgain/react-select-event/commit/7e4b980288b1195d847966951c542278441a396c
Please, let me know if you have any other issues!
@JLFullstack
Oh, I see. That’s actually an issue with newer versions of @testing-library/react, not with react-select-event. It’s documented under the “MutationObserver shim removed” breaking change here: https://github.com/testing-library/dom-testing-library/releases/tag/v7.0.0
You can fix it by installing
jest-environment-jsdom-sixteen
and updating your test script:Let me know if you have any other issues!