Testing React: Target Container is not a DOM element

前端 未结 5 911
悲哀的现实
悲哀的现实 2020-12-16 09:27

I\'m attempting to test a React component with Jest/Enzyme while using Webpack.

I have a very simple test @

import React from \'react\';
import { sha         


        
5条回答
  •  独厮守ぢ
    2020-12-16 10:16

    For anyone else that was combing through the internet like I've been - looking for a solution to this when testing with Jest - I will back up the answer by @biphobe by saying Jest will cause this error to occur when you export something inside the same file that is calling ReactDOM.render.

    In my case, I was exporting an object within my index.js where I was also calling ReactDOM.render. I removed this export and voila!

提交回复
热议问题