Skip to content

Bug: react@19 renders always null with react-test-renderer@19  #34204

@AndyOGo

Description

@AndyOGo

React version: 19

Steps To Reproduce

  1. npm install react@19 react-test-renderer@19
  2. use create and call toJSON()/toTree() APIs
import assert = require("node:assert");
import { create } from "react-test-renderer";

const testRenderer = create(<div />);

try {
  assert(testRenderer.toJSON(), "JSON should not be null");
} catch (error) {
  console.error(error);
}

try {
  assert(testRenderer.toTree(), "Tree should not be null");
} catch (error) {
  console.error(error);
}

Link to code example:
https://codesandbox.io/p/devbox/elegant-kepler-224hrz?workspaceId=ws_AUrTGk3RTnAN4nJ64LUUVP

The current behavior

When migrating to React 19 then react-test-renderer always renders null and the root has no children.

The expected behavior

When migrating to React 19 then react-test-renderer should still render and the root should have children.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions