question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
darseecommented, Aug 27, 2019

Is this because Provider is now a functional component?

I think the discussion in https://github.com/facebook/react/issues/15370 is relevant.

1reaction
timdorrcommented, 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found