Skip to content

Commit cb1db43

Browse files
committed
Avoid warning in Modal test
This avoids the following warning. Although the test setup adds a div with id of "app", that's not in the dom at the point the InputModal attempts to find it with `document.querySelector("#app")` and `document.getElementById("app")`. console.error Warning: react-modal: App element is not defined. Please use `Modal.setAppElement(el)` or set `appElement={el}`. This is needed so screen readers don't see main content when modal is opened. It is not recommended, but you can opt-out by setting `ariaHideApp={false}`.
1 parent 04825c3 commit cb1db43

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/components/Modals/InputModal.test.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ beforeEach(() => {
1515
},
1616
};
1717
const store = mockStore(initialState);
18+
const app = document.createElement("div");
19+
app.setAttribute("id", "app");
20+
document.body.appendChild(app);
1821
render(
1922
<Provider store={store}>
20-
<div id="app">
21-
<InputModal
22-
isOpen={true}
23-
inputs={[
24-
{
25-
label: "input",
26-
helpText: "help me",
27-
value: "my amazing default",
28-
},
29-
]}
30-
/>
31-
</div>
23+
<InputModal
24+
isOpen={true}
25+
inputs={[
26+
{
27+
label: "input",
28+
helpText: "help me",
29+
value: "my amazing default",
30+
},
31+
]}
32+
/>,
3233
</Provider>,
3334
);
3435
inputBox = screen.getByLabelText(/input/);

0 commit comments

Comments
 (0)