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

Update test warning content #6775

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/content/warnings/react-test-renderer.md
Expand Up @@ -4,11 +4,24 @@ title: react-test-renderer Deprecation Warnings

## ReactTestRenderer.create() warning {/*reacttestrenderercreate-warning*/}

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.
`react-test-renderer` is deprecated. An error will log whenever calling ReactTestRenderer.create(). The package will remain available on NPM but will not be maintained and will break with new React features or changes to React's internals.

<Note>
The React Team recommends migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://callstack.github.io/react-native-testing-library/docs/getting-started) for a modern and well supported testing experience.

If your application has extensive `react-test-renderer` usage, consider pinning the package to an alias such as `react-test-renderer-18-DO_NOT_USE` and incrementally migrating to `testing-library`.

Tests using deprecated renderers will effectively be stuck on an old version and will not work with new React features such as Actions.
</Note>

## new ShallowRenderer() warning {/*new-shallowrenderer-warning*/}

The react-test-renderer package no longer exports a shallow renderer at `react-test-renderer/shallow`. This was simply a repackaging of a previously extracted separate package: `react-shallow-renderer`. Therefore you can continue using the shallow renderer in the same way by installing it directly. See [Github](https://github.com/enzymejs/react-shallow-renderer) / [NPM](https://www.npmjs.com/package/react-shallow-renderer).
Shallow rendering is no longer supported. As of React 19, the `react-test-renderer` package no longer exports a renderer at `react-test-renderer/shallow` and you will get an error when creating a `ShallowRenderer` instance.

<Note>
The React Team recommends migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) or [@testing-library/react-native](https://callstack.github.io/react-native-testing-library/docs/getting-started) for a modern and well supported testing experience.

If your application has extensive `react-test-renderer/shallow` usage, consider installing the external package, [`react-shallow-renderer`](https://www.npmjs.com/package/react-shallow-renderer), pinning it to an alias such as `react-shallow-renderer-18-DO_NOT_USE`, and incrementally migrating to `testing-library`.

Tests using deprecated renderers will effectively be stuck on an old version and will not work with new React features such as Actions.
</Note>