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

Commit

Permalink
fix: better error message on missing support file (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored May 1, 2020
1 parent 393b273 commit 436f3bb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ export const mount = (jsx: React.ReactElement, options: MountOptions = {}) => {

const el = document.getElementById(rootId)

if (!el) {
throw new Error(
[
'[cypress-react-unit-test] 🔥 Hmm, cannot find root element to mount the component.',
'Did you forget to include the support file?',
'Check https://github.com/bahmutov/cypress-react-unit-test#install please',
].join(' '),
)
}

const key =
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
(Cypress?.mocha?.getRunner()?.test?.title || '') + Math.random()
Expand Down

0 comments on commit 436f3bb

Please sign in to comment.