testing-library / react-testing-library

🐐 Simple and complete React DOM testing utilities that encourage good testing practices.
https://testing-library.com/react
MIT License
19.04k stars 1.11k forks source link

Support React 18.3 #1314

Closed christopherschroer closed 7 months ago

christopherschroer commented 7 months ago

Describe the feature you'd like:

I would like react-testing-library to support the newly released React 18.3. According to react.dev:

To help make the upgrade to React 19 easier, we’ve published a react@18.3 release that is identical to 18.2 but adds warnings for deprecated APIs and other changes that are needed for React 19.

We recommend upgrading to React 18.3 first to help identify any issues before upgrading to React 19.

For a list of changes in 18.3 see the Release Notes.

Suggested implementation:

React.dev provides an upgrade guide for React 19 Beta here. I would suggest reviewing it and implementing applicable changes as part of supporting React 18.3/19.

One of the changes that is causing warnings to be logged concerns the act function

https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-react-dom-test-utils

Describe alternatives you've considered:

Not upgrading to React 18.3 yet in order to keep test logs clean

Teachability, Documentation, Adoption, Migration Strategy:

Following the above upgrade guide as needed

ambar-arkin commented 7 months ago

This is a bug in react 18.3 https://github.com/facebook/react/issues/28915

Act change is already implemented in testing library https://github.com/testing-library/react-testing-library/blob/48282c2f35fb7338834b40983c12b889af35f5d1/src/act-compat.js#L5

MatanBobi commented 7 months ago

Thanks for reporting this. I'm closing in favor of https://github.com/facebook/react/issues/28915 as we already implemented this as @ambar-arkin mentioned.