Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit 436f3bb

Browse files
authored
fix: better error message on missing support file (#162)
1 parent 393b273 commit 436f3bb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ export const mount = (jsx: React.ReactElement, options: MountOptions = {}) => {
6464

6565
const el = document.getElementById(rootId)
6666

67+
if (!el) {
68+
throw new Error(
69+
[
70+
'[cypress-react-unit-test] 🔥 Hmm, cannot find root element to mount the component.',
71+
'Did you forget to include the support file?',
72+
'Check https://github.com/bahmutov/cypress-react-unit-test#install please',
73+
].join(' '),
74+
)
75+
}
76+
6777
const key =
6878
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
6979
(Cypress?.mocha?.getRunner()?.test?.title || '') + Math.random()

0 commit comments

Comments
 (0)