setAppElement throws error in tests
See original GitHub issueSummary:
When running in test
, the lib/helpers/ariaAppHider.js:24
throws:
Error: react-modal: No elements were found for selector #app.
Expected behavior:
Should not throw errors in test.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:25
- Comments:18
Top Results From Across the Web
"Warning: react-modal: App element is not defined. Please ...
setAppElement ('root'); from inside src/index.js , where root is the root element that my App component is injected into, and index.js is where...
Read more >Successfully Throwing Async Errors with the Jest Testing Library
Today, I'll discuss how to successfully test expected errors are thrown with the popular JavaScript testing library Jest, so you can rest ...
Read more >Warning: react-modal: App element is not defined. Please use ...
Coding example for the question "Warning: react-modal: App element is not defined. Please use `Modal.setAppElement(el)` or set `appElement={el}`"-Reactjs.
Read more >Modals | Testing Library
import {render, fireEvent} from '@testing-library/react' const modalRoot = document.createElement('div') modalRoot.
Read more >setAppElement - react-modal documentation
Using setAppElement. This example shows how to use setAppElement to properly hide your application from screenreaders and other assistive technologies while ...
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
In order to fix this issue, I did the following in all my components that use react-modal:
I too am having the same issue, #668 didn’t fix this for me.