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] Disallow unasserted console.log #28708

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

rickhanlonii
Copy link
Member

Followup from #28693 and #28680.

In CI, we fail the test for any unasserted console.log. In DEV, we don't fail, but you can still use the matchers and we'll assert on them.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 1, 2024
@@ -35,6 +35,9 @@ describe('ReactStrictMode', () => {
});

it('should appear in the client component stack', async () => {
// TODO REMOVE AFTER TESTING THIS FAILS ON PR
console.log('hit');
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm expecting the test to fail just to confirm the CI envar is set properly, then I'll remove this.

@react-sizebot
Copy link

react-sizebot commented Apr 1, 2024

Comparing: 95e6f03...b98343b

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 = 177.10 kB 177.10 kB = 55.05 kB 55.05 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 172.94 kB 172.94 kB = 53.91 kB 53.91 kB
facebook-www/ReactDOM-prod.classic.js = 592.68 kB 592.68 kB = 103.96 kB 103.96 kB
facebook-www/ReactDOM-prod.modern.js = 574.37 kB 574.37 kB = 100.98 kB 100.98 kB
test_utils/ReactAllWarnings.js Deleted 64.93 kB 0.00 kB Deleted 16.24 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
test_utils/ReactAllWarnings.js Deleted 64.93 kB 0.00 kB Deleted 16.24 kB 0.00 kB

Generated by 🚫 dangerJS against b98343b

Copy link
Member

@kassens kassens left a comment

Choose a reason for hiding this comment

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

We could also get a more uniform behavior and easier code if we always disallow console.log, and just use console.debug for local debugging.
Don't have a strong preference through. If tests pass and you remove the temporary code to test that this behaves correctly in CI, sounds good to me.

@rickhanlonii
Copy link
Member Author

Yeah it would be super annoying to have to use console.debug in DEV

@kassens
Copy link
Member

kassens commented Apr 1, 2024

Isn't console.debug basically the same in Node? Anyway, really happy with this either way as it's easy to regress and have tests log walls of text.

@rickhanlonii rickhanlonii merged commit 6e65010 into facebook:main Apr 1, 2024
38 checks passed
@rickhanlonii rickhanlonii deleted the rh/to-log-dev branch April 2, 2024 13:24
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Followup from facebook#28693 and
facebook#28680.

In CI, we fail the test for any unasserted console.log. In DEV, we don't
fail, but you can still use the matchers and we'll assert on them.
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.

None yet

4 participants