Skip to content

5.5.3 breaks testing for React 15 #287

Closed
@alexzherdev

Description

@alexzherdev
  • 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions