testing-library/react-testing-library

16.1.0 breaks tests using React 18

gismya opened this issue · 2 comments

gismya commented
  • @testing-library/react version: 16.1.0
  • Testing Framework and version:
    Vitest 2.0.5
  • DOM Environment:
    JSDOM 25.0.1

Relevant code or config:

npm run update;

What you did:

Updated @testing-library/react from 16.0.1 to 16.1.0

What happened:

My tests using @testing-library/react started throwing errors.

Error: A React Element from an older version of React was rendered. This is not supported. It can happen if:
- Multiple copies of the "react" package is used.
- A library pre-bundled an old copy of "react" or "react/jsx-runtime".
- A compiler tries to "inline" JSX instead of using the runtime.

Problem description:

Not sure if it's a general issue or specific to our usage. We are only using it in one test file, and the methods we are importing and using are act, renderHook, waitFor.

Can you provide a minimal repro? I quickly scanned our published code and couldn't find an instance where we inlined the JSX runtime. Double check if this reproduces with a simple render(<p />) or if it's maybe specific to the component you're rendering and more specifically, the components from 3rd party dependencies you're using.

gismya commented

Okay, minimal reproductions work, so it is not quite as straight forward as I thought. Must be some other interaction that breaks when updating, but I can't tell straight away what. I'm closing this and I'll come back if I stumble upon some useful clues or something that's reproducible outside our specific circumstances.