jest icon indicating copy to clipboard operation
jest copied to clipboard

[Docs]: `react-test-renderer` deprecated

Open AndyOGo opened this issue 1 year ago • 29 comments

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-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

AndyOGo avatar Jun 27 '24 19:06 AndyOGo

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?

mrazauskas avatar Jun 28 '24 11:06 mrazauskas

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

AndyOGo avatar Jul 01 '24 10:07 AndyOGo

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.

mrazauskas avatar Jul 01 '24 14:07 mrazauskas

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.

github-actions[bot] avatar Jul 31 '24 15:07 github-actions[bot]

@facebook-github-bot this isn't resolved yet

AndyOGo avatar Jul 31 '24 20:07 AndyOGo

Happy to just delete the articles, if you're up for sending a PR

SimenB avatar Aug 01 '24 07:08 SimenB

@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

AndyOGo avatar Aug 01 '24 14:08 AndyOGo

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.

github-actions[bot] avatar Aug 31 '24 15:08 github-actions[bot]

+1

AndyOGo avatar Sep 01 '24 16:09 AndyOGo

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.

github-actions[bot] avatar Oct 01 '24 18:10 github-actions[bot]

+1

AndyOGo avatar Oct 01 '24 19:10 AndyOGo

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.

github-actions[bot] avatar Oct 31 '24 20:10 github-actions[bot]

+1

AndyOGo avatar Oct 31 '24 20:10 AndyOGo

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

sebastiancarlos avatar Nov 07 '24 15:11 sebastiancarlos

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.

github-actions[bot] avatar Dec 07 '24 16:12 github-actions[bot]

+1

AndyOGo avatar Dec 07 '24 16:12 AndyOGo

+1

VictorRutskin avatar Dec 25 '24 13:12 VictorRutskin

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.

github-actions[bot] avatar Jan 24 '25 14:01 github-actions[bot]

+1

AndyOGo avatar Jan 24 '25 15:01 AndyOGo

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.

github-actions[bot] avatar Feb 23 '25 17:02 github-actions[bot]

+1

AndyOGo avatar Feb 23 '25 17:02 AndyOGo

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.

github-actions[bot] avatar Mar 25 '25 18:03 github-actions[bot]

+ayylmao

sebastiancarlos avatar Mar 25 '25 18:03 sebastiancarlos

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.

github-actions[bot] avatar Apr 24 '25 19:04 github-actions[bot]

not today bot

sebastiancarlos avatar Apr 24 '25 19:04 sebastiancarlos

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.

github-actions[bot] avatar May 24 '25 21:05 github-actions[bot]

+1

AndyOGo avatar May 25 '25 08:05 AndyOGo

+1

mario8a avatar May 29 '25 22:05 mario8a

+1

Naman-Jangid avatar May 30 '25 05:05 Naman-Jangid