Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from 7.1.0 to 7.1.1 broke karma/mocha testcases with ReactTestUtils.renderIntoDocument #1388

Closed
vlsergey opened this issue Aug 27, 2019 · 5 comments

Comments

@vlsergey
Copy link

Do 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",
@vlsergey vlsergey changed the title Update from 7.1.0 to 7.1.1 breaks karma/mocha testcases with ReactTestUtils.renderIntoDocument Upgrade from 7.1.0 to 7.1.1 broke karma/mocha testcases with ReactTestUtils.renderIntoDocument Aug 27, 2019
@timdorr
Copy link
Member

timdorr commented Aug 27, 2019

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.

@timdorr timdorr closed this as completed Aug 27, 2019
@darsee
Copy link

darsee commented Aug 27, 2019

Is this because Provider is now a functional component?

I think the discussion in facebook/react#15370 is relevant.

@vlsergey
Copy link
Author

@darsee , thanks for the link. That is exactly what happens.

@timdorr, I agree that not a bug, but such change should not appear in semver patch release, IMHO.

@timdorr
Copy link
Member

timdorr commented Aug 27, 2019

The API hasn't changed, so we haven't broken semver.

@warwick-ava
Copy link

I am getting a similar error upon upgrade to 7.1.1 in use with enzyme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants