question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setAppElement throws error in tests

See original GitHub issue

Summary:

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:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:18

github_iconTop GitHub Comments

85reactions
nickavcommented, Apr 4, 2018

In order to fix this issue, I did the following in all my components that use react-modal:

if (process.env.NODE_ENV !== 'test') ReactModal.setAppElement('#app');
12reactions
glentakahashicommented, Dec 5, 2018

I too am having the same issue, #668 didn’t fix this for me.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found