jest
jest copied to clipboard
[Docs]: `react-test-renderer` deprecated
Page(s)
- https://jestjs.io/docs/tutorial-react
- https://jestjs.io/docs/tutorial-react-native#snapshot-test
Description
react-test-renderer is deprecated.
react-test-rendereris deprecated. A warning will fire whenever callingReactTestRenderer.create()orReactShallowRender.render(). Thereact-test-rendererpackage 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-rendereris deprecated and no longer maintained. It will be removed in a future version. As of React 19, you will see a console warning when invokingReactTestRenderer.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
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?
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
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.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
@facebook-github-bot this isn't resolved yet
Happy to just delete the articles, if you're up for sending a PR
@SimenB
The deprecation of react-test-renderer affects more than just those doc pages.
IMHO someone who knows this repo well should take care to analyze and to carry out all of the required changes.
A quick search reveals at least something of what has to be done - it seems pretty-format has some implicit or explicit dependency too (just a guess):
:https://github.com/search?q=repo%3Ajestjs%2Fjest%20react-test-renderer&type=code
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
It does seem that people use React Testing Library for snapshot testing too: https://stackoverflow.com/questions/66362759/react-snapshot-testing-react-test-renderer-vs-react-testing-library
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
+1
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+ayylmao
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
not today bot
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
+1
+1
+1