score:0
I had that same problem, which in my case occurred because React couldn't find the element in which it needed to render the html.
I found a quick fix by adding the following if statement into my main js file:
if ($('#container').length <= 0) {
$('body').prepend('<div id="container"></div>');
}
ReactDom.render(
<App />,
document.getElementById('container')
);
I'm aware this must not be the best way of fixing it, but at least it works for now. If anyone knows of a better way, please let us know!
score:0
Code you are covering is trying to render component into DOM node. Your code relys that it already exists (somewhere in index.html or whatever). But PhantomJS cannot find that DOM node. You should create it before calling ReactDOM.render or search how to change template of html page used by phantom to run tests (there are plugins doung this).
Source: stackoverflow.com
Related Query
- Karma Coverage and Babel+Browserify Preprocessing
- Karma and React, have warnings to cause errors
- Difference between statement and line coverage in jest
- Sonarqube coverage configuration for React and Jest
- Karma + Browserify + Jasmine + Istanbul + React coverage
- How to get full test coverage with Jest and ReactJS, currently at 90.48% statements, 58.06% branch
- Unit testing react using Karma and Jasmine
- Get code coverage from Cypress with babel, nyc and istanbul plugin?
- How to get line coverage on React.useEffect hook when using Jest and enzyme?
- Code coverage concern on promise/asynchronous unit testing using nockjs and jest
- How to properly unit test ReactDOM.render with Karma and PhantomJS?
- SonarQube with Jest and react - Coverage on 0 New Lines to cover
- How to use Karma and Jest together in unit testing React application?
- How to solve Webpack 2 and Karma MemoryFileSystem error?
- Generate coverage with Mocha and Istanbul
- How to write test case coverage in Jest and Enzyme for indexOf used inside React Component
- Webpack and Karma Testing: Uncaught ReferenceError: jQuery is not defined using
- What is the difference between React Native and React?
- Difference between npx and npm?
- What is the difference between state and props in React?
- What's the difference between "super()" and "super(props)" in React when using es6 classes?
- TypeScript and React - children type?
- Trying to use fetch and pass in mode: no-cors
- where is create-react-app webpack config and files?
- How to compare oldValues and newValues on React Hooks useEffect?
- React : difference between <Route exact path="/" /> and <Route path="/" />
- Understanding React-Redux and mapStateToProps()
- How do you test for the non-existence of an element using jest and react-testing-library?
- How to have conditional elements and keep DRY with Facebook React's JSX?
- Concatenating variables and strings in React
More Query from same tag
- using redux-persist with redux thunk
- Cannot send email with EmailJS/React
- Build a dynamic string to filter a rest call
- Normalize api response with normalizr
- Preparing JSON data into a JavaScript array to use in react-heatmap-grid React app
- Javascript: Filter list of objects by a list of filter objects
- How can I jest-test a custom callback used with third-party API?
- Custom hook's state does not update across all components?
- React-Redux, cannot set a value to an empty string
- Authorization header not present on page refresh
- airbnb/react-dates Display Week Number on DayPickerRangeController
- React-Bootstrap Cards Stretching Images
- Missing state value after function binding in React
- React newbie: sharing state across unlinked components
- How to pass a state without to import component ReactJS?
- React - passing props to parent
- Next.js: How to create get request using React Query
- Can't any data from a checkbox
- How to subscribe to a Redux action in a React component
- react-places-autocomplete restrictions
- Component not displayed - React
- Create an axios call that will update state and then perform another one
- How to use react router to achieve step by step navigation (like in a slideshow)?
- Reducer in deeply nested state
- Sending a state to a parent component
- Running react-tippy in jsfiddle
- react javascript API Data Date Today Date Comparison
- error "Converting circular structure to JSON -> starting at object with constructor 'FiberNode'" in react native
- Spotify WebPlayer API - Change Player Request
- Getting an error on using setRouteLeaveHook (withRouter)