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

Deprecate act from react-dom/test-utils in favor of act from react #28597

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Mar 20, 2024

Stacked on #28541

Summary

Use React.act instead:

-import {act} from 'react-dom/test-utils'
+import {act} from 'react'

How did you test this change?

  • using React.act now instead of ReactDOMTestUtils when testing the public act
  • added test for the new warning

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 20, 2024
@react-sizebot
Copy link

react-sizebot commented Mar 20, 2024

Comparing: ec4d26c...d8733fa

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 176.92 kB 176.92 kB = 54.99 kB 54.99 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 173.10 kB 173.10 kB = 53.94 kB 53.94 kB
facebook-www/ReactDOM-prod.classic.js = 592.31 kB 592.31 kB = 103.83 kB 103.83 kB
facebook-www/ReactDOM-prod.modern.js = 573.20 kB 573.20 kB = 100.71 kB 100.71 kB
oss-experimental/react-dom/cjs/react-dom-test-utils.development.js +5.99% 26.38 kB 27.96 kB +8.76% 7.19 kB 7.82 kB
oss-experimental/react-dom/umd/react-dom-test-utils.development.js +5.88% 28.06 kB 29.71 kB +8.51% 7.34 kB 7.97 kB
oss-experimental/react-dom/cjs/react-dom-test-utils.production.min.js +2.87% 8.59 kB 8.84 kB +3.22% 2.67 kB 2.76 kB
oss-experimental/react-dom/umd/react-dom-test-utils.production.min.js +2.83% 8.73 kB 8.98 kB +2.70% 2.75 kB 2.82 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.production.min.js +2.07% 11.94 kB 12.19 kB +2.58% 4.66 kB 4.78 kB
oss-stable/react-dom/cjs/react-dom-test-utils.production.min.js +2.07% 11.94 kB 12.19 kB +2.58% 4.66 kB 4.78 kB
oss-stable-semver/react-dom/umd/react-dom-test-utils.production.min.js +2.04% 12.03 kB 12.28 kB +2.77% 4.70 kB 4.83 kB
oss-stable/react-dom/umd/react-dom-test-utils.production.min.js +2.04% 12.03 kB 12.28 kB +2.77% 4.70 kB 4.83 kB
test_utils/ReactAllWarnings.js Deleted 65.07 kB 0.00 kB Deleted 16.27 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/cjs/react-dom-test-utils.development.js +5.99% 26.38 kB 27.96 kB +8.76% 7.19 kB 7.82 kB
oss-experimental/react-dom/umd/react-dom-test-utils.development.js +5.88% 28.06 kB 29.71 kB +8.51% 7.34 kB 7.97 kB
oss-experimental/react-dom/cjs/react-dom-test-utils.production.min.js +2.87% 8.59 kB 8.84 kB +3.22% 2.67 kB 2.76 kB
oss-experimental/react-dom/umd/react-dom-test-utils.production.min.js +2.83% 8.73 kB 8.98 kB +2.70% 2.75 kB 2.82 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.production.min.js +2.07% 11.94 kB 12.19 kB +2.58% 4.66 kB 4.78 kB
oss-stable/react-dom/cjs/react-dom-test-utils.production.min.js +2.07% 11.94 kB 12.19 kB +2.58% 4.66 kB 4.78 kB
oss-stable-semver/react-dom/umd/react-dom-test-utils.production.min.js +2.04% 12.03 kB 12.28 kB +2.77% 4.70 kB 4.83 kB
oss-stable/react-dom/umd/react-dom-test-utils.production.min.js +2.04% 12.03 kB 12.28 kB +2.77% 4.70 kB 4.83 kB
oss-experimental/react-dom/cjs/react-dom-test-utils.production.js +1.20% 26.34 kB 26.65 kB +0.95% 7.16 kB 7.23 kB
facebook-www/ReactTestUtils-dev.classic.js +0.60% 51.14 kB 51.45 kB +0.38% 13.07 kB 13.12 kB
facebook-www/ReactTestUtils-dev.modern.js +0.60% 51.14 kB 51.45 kB +0.38% 13.07 kB 13.12 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.production.js +0.57% 42.65 kB 42.90 kB +0.50% 12.11 kB 12.17 kB
oss-stable/react-dom/cjs/react-dom-test-utils.production.js +0.57% 42.65 kB 42.90 kB +0.50% 12.11 kB 12.17 kB
oss-stable-semver/react-dom/cjs/react-dom-test-utils.development.js +0.53% 44.65 kB 44.89 kB +0.35% 12.88 kB 12.92 kB
oss-stable/react-dom/cjs/react-dom-test-utils.development.js +0.53% 44.65 kB 44.89 kB +0.35% 12.88 kB 12.92 kB
oss-stable-semver/react-dom/umd/react-dom-test-utils.development.js +0.53% 47.42 kB 47.67 kB +0.36% 13.10 kB 13.15 kB
oss-stable/react-dom/umd/react-dom-test-utils.development.js +0.53% 47.42 kB 47.67 kB +0.36% 13.10 kB 13.15 kB
test_utils/ReactAllWarnings.js Deleted 65.07 kB 0.00 kB Deleted 16.27 kB 0.00 kB

Generated by 🚫 dangerJS against d8733fa

@eps1lon eps1lon marked this pull request as ready for review March 20, 2024 20:24
it('throws on every removed function with a special message', async () => {
expect(ReactTestUtils.isDOMComponent).toThrowError(
'`isDOMComponent` was removed from `react-dom/test-utils`. ' +
'For testing React, we recommend React Testing Library instead: https://testing-library.com/docs/react-testing-library/intro.',
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the react-test-renderer warning, I don't think we should hard code the recommendations into the error message, instead something like:

isDOMComponent was removed from react-dom/test-utils. See https://react.dev/warnings/react-test-renderer for more info.

Copy link
Member

Choose a reason for hiding this comment

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

Ditto for the other warning messages added here.

Copy link
Member

Choose a reason for hiding this comment

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

And we can update that warning page with info on which methods were removed, and why we removed them.

@eps1lon eps1lon force-pushed the dom/test-utils-act-warning branch 2 times, most recently from 42124b8 to eed0ea4 Compare March 23, 2024 21:26
@eps1lon eps1lon merged commit 2b036d3 into facebook:main Mar 27, 2024
38 checks passed
@eps1lon eps1lon deleted the dom/test-utils-act-warning branch March 27, 2024 15:28
github-actions bot pushed a commit that referenced this pull request Mar 27, 2024
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team React 19
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants