Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs]: react-test-renderer deprecated #15150

Open
AndyOGo opened this issue Jun 27, 2024 · 3 comments
Open

[Docs]: react-test-renderer deprecated #15150

AndyOGo opened this issue Jun 27, 2024 · 3 comments

Comments

@AndyOGo
Copy link

AndyOGo commented Jun 27, 2024

Page(s)

Description

react-test-renderer is deprecated.

react-test-renderer is deprecated. A warning will fire whenever calling ReactTestRenderer.create() or ReactShallowRender.render(). The react-test-renderer package will remain available on NPM but will not be maintained and may break with new React features or changes to React’s internals.
https://react.dev/warnings/react-test-renderer

react-test-renderer is deprecated and no longer maintained. It will be removed in a future version. As of React 19, you will see a console warning when invoking ReactTestRenderer.create().
https://www.npmjs.com/package/react-test-renderer/v/19.0.0-canary-8afa144bd-20240416?activeTab=readme#react-test-renderer-deprecated

Note: that affects any code using react-test-renderer
https://github.com/search?q=repo%3Ajestjs%2Fjest%20react-test-renderer&type=code

@mrazauskas
Copy link
Contributor

The React 19 RC Upgrade Guide says:

We recommend migrating your tests to @testing-library/react or @testing-library/react-native for a modern and well supported testing experience.

So I guess Jest's docs and examples should be updated accordingly. @AndyOGo would you be up to putting together a PR?

@AndyOGo
Copy link
Author

AndyOGo commented Jul 1, 2024

Thanks for your quick reply @mrazauskas

Well @testing-library/react is a library to write integration tests, it doesn't support shallow snapshot testing nor snapshot diffing.

IMHO these testing approaches pose an anti-pattern and promote bad practices, completely invalidating the first layer of the testing pyramid - unit tests.
https://martinfowler.com/articles/practical-test-pyramid.html

@mrazauskas
Copy link
Contributor

So perhaps both pages (Testing React Apps and Testing React Native Apps) should be simply removed?

I see that https://jestjs.io/docs/testing-frameworks already includes @testing-library/react under the Testing ReactJS components with Jest entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants