diff --git a/client/src/components/atoms/Modal.test.tsx b/client/src/components/atoms/Modal.test.tsx
index a9861eb..81130f8 100644
--- a/client/src/components/atoms/Modal.test.tsx
+++ b/client/src/components/atoms/Modal.test.tsx
@@ -1,14 +1,17 @@
import React from 'react'
import { render } from '@testing-library/react'
import Modal from './Modal'
+import ReactModal from 'react-modal'
describe('Modal', () => {
it('renders without crashing', () => {
- const { container } = render(
+ ReactModal.setAppElement(document.createElement('div'))
+
+ render(
null}>
Hello
)
- expect(container.firstChild).toBeInTheDocument()
+ expect(document.querySelector('.ReactModalPortal')).toBeInTheDocument()
})
})
diff --git a/client/src/components/atoms/Modal.tsx b/client/src/components/atoms/Modal.tsx
index 7b99105..d3b5c7e 100644
--- a/client/src/components/atoms/Modal.tsx
+++ b/client/src/components/atoms/Modal.tsx
@@ -2,7 +2,7 @@ import React from 'react'
import ReactModal from 'react-modal'
import styles from './Modal.module.scss'
-ReactModal.setAppElement('#root')
+if (process.env.NODE_ENV !== 'test') ReactModal.setAppElement('#root')
const Modal = ({
title,
@@ -11,7 +11,8 @@ const Modal = ({
toggleModal,
children,
onAfterOpen,
- onRequestClose
+ onRequestClose,
+ ...props
}: {
title: string
description?: string
@@ -29,6 +30,7 @@ const Modal = ({
contentLabel={title}
className={styles.modal}
overlayClassName={styles.modalOverlay}
+ {...props}
>