Skip to content

Render doesn't render the same result in react 19Β #1408

@michielmetcake

Description

@michielmetcake
  • @testing-library/react version: 16.3.0
  • Testing Framework and version:
    "jest": "^30.0.5",
  • DOM Environment:
    "jest-environment-jsdom": "^30.0.5",

Relevant code or config:

import { render } from "@testing-library/react";

describe( () => {
  it(() => {
    const {container} = render(<link rel="preconnect" key="bla" href='/bla' />);

    expect(container).toMatchSnapshot()
  });
});

What you did:

We want to update to react 19. But the tests made with testing-library are failing.

What happened:

When running the test from above this is the snapshot we receive:

    - Snapshot  - 6
    + Received  + 1

    - <div>
    -   <link
    -     href="/bla"
    -     rel="preconnect"
    -   />
    - </div>
    + <div />

Reproduction:

https://codesandbox.io/p/devbox/zf2xft?file=%2Fpackage.json%3A14%2C3-15%2C26

Change the version of react to:

"react": "19.1.0",
"react-dom": "19.1.0"

Problem description:

  • inconsistent testing response between react versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions