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 1 commit
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
13 changes: 11 additions & 2 deletions src/content/warnings/react-test-renderer.md
Expand Up @@ -4,11 +4,20 @@ 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-DO_NOT_USE` and incrementally migrating to `testing-library`. When your tests have been migrated, you can upgrade to React 19 with more confidence.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pinning strategy is to not block upgrading to 19, so you don't need to upgrade them all at first. The caveat is that you won't be able to use 19 features like actions in your tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

</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-DO_NOT_USE`, and incrementally migrating to `testing-library`. When your tests have been migrated, you can upgrade to React 19 with more confidence.
</Note>