Upgrade from 7.1.0 to 7.1.1 broke karma/mocha testcases with ReactTestUtils.renderIntoDocument
See original GitHub issueDo you want to request a feature or report a bug?
bug
What is the current behavior?
Starting from 7.1.1 result of ReactTestUtils.renderIntoDocument( <Provider> )
is null
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
describe( 'react-redux', () => {
it( 'can render Provider with ReactTestUtils', () => {
const fakeReducers = ( state = {} ) => state;
const fakeStore = createStore( fakeReducers );
const rendered = ReactTestUtils.renderIntoDocument( <Provider store={fakeStore}>
<div>Hello, World!</div>
</Provider> );
if ( !rendered ) throw new Error( 'Unable to render, ' +
'result of renderIntoDocument() is ' + rendered );
} );
} );
What is the expected behavior?
Expected result (works for 7.1.0): test passed Current result (7.1.1): Unable to render, result of renderIntoDocument() is null
Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
"jsdom": "^15.1.1",
"karma": "^4.2.0",
"karma-chrome-launcher": "^3.1.0",
"karma-jsdom-launcher": "^7.1.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
...
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Test with reactjs renderIntoDocument keep failed due to ...
tl;dr; You need jsdom + Mocha . According to spec ReactTestUtils#renderIntoDocument ,. renderIntoDocument() requires a DOM: You will need to have window, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this because
Provider
is now a functional component?I think the discussion in https://github.com/facebook/react/issues/15370 is relevant.
I’m not sure renderIntoDocument is supposed to return anything. Their docs don’t mention it: https://reactjs.org/docs/test-utils.html#renderintodocument
I would do as the example in that section shows and create a DOM element explicitly and then use render on it.