Skip to content

5.5.3 breaks testing for React 15 #287

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

Closed
alexzherdev opened this issue Feb 8, 2019 · 2 comments · Fixed by #288
Closed

5.5.3 breaks testing for React 15 #287

alexzherdev opened this issue Feb 8, 2019 · 2 comments · Fixed by #288
Labels

Comments

@alexzherdev
Copy link
Contributor

  • react-testing-library version: 5.5.3
  • react version: 15.6.2
  • node version: 10
  • npm (or yarn) version: yarn 1.13

Relevant code or config:

import React from "react";
import { render } from "react-testing-library";
render(<div />);

What you did:

Just recently installed the library and was trying to write my first tests. Everything was working fine until I updated to 5.5.3.

What happened:

Trying to render anything in tests results in ReactDOM.render(): Invalid component element.

Reproduction:

https://codesandbox.io/s/lxzrym3p9q

Problem description:

This seems to be the culprit: https://github.com/kentcdodds/react-testing-library/blob/1d45c5c2ca1281187dc7735ac0e2f12137b157d3/src/act-compat.js#L10
Rendering null only works in React 16, not in 15.x.

Suggested solution:

I'm actually not too sure why that line is necessary in the first place. Why is just calling ReactDOM.unstable_batchedUpdates not enough?

@kentcdodds
Copy link
Member

Ah, yep, that'll do it. The fix is to render <div /> instead of null. Want to make a pull request for that?

alexzherdev pushed a commit to alexzherdev/react-testing-library that referenced this issue Feb 8, 2019
alexzherdev pushed a commit to alexzherdev/react-testing-library that referenced this issue Feb 8, 2019
kentcdodds pushed a commit that referenced this issue Feb 8, 2019
@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 5.5.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants