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

[tests] fix hidden use() warnings #31984

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

rickhanlonii
Copy link
Member

spyOnDev is such a footgun.

Copy link

vercel bot commented Jan 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 5:30am

@@ -561,6 +577,7 @@ describe('ReactUse', () => {
'triggered by `use`, wrap your component in a error boundary.',
);
}
console.error.mockRestore();
Copy link
Member Author

Choose a reason for hiding this comment

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

If you don't restore the mock at the end of a test using spyOnDev, all tests after it will have the console errors silenced and break the toErrorDev / assertConsoleErrorDev tests.

This quick fix isn't the best either because if this test fails, the mock won't restore so test after it will fail even though they pass. The best would be to restore in an afterEach in setupTests.js, but that will fail a bunch of tests so I'll follow up with that.

@react-sizebot
Copy link

react-sizebot commented Jan 5, 2025

Comparing: 03e4ec2...247b671

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.js = 6.68 kB 6.68 kB +0.11% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 512.56 kB 512.56 kB = 91.61 kB 91.61 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 517.34 kB 517.34 kB = 92.46 kB 92.46 kB
facebook-www/ReactDOM-prod.classic.js = 594.36 kB 594.36 kB = 104.68 kB 104.69 kB
facebook-www/ReactDOM-prod.modern.js = 584.62 kB 584.62 kB = 103.13 kB 103.14 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against f67863c

@rickhanlonii rickhanlonii merged commit 83be48b into facebook:main Jan 6, 2025
187 checks passed
@rickhanlonii rickhanlonii deleted the rh/fix-react-use-warnings branch January 6, 2025 19:12
rickhanlonii added a commit that referenced this pull request Jan 6, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants