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

Suppress console output in unit tests #28680

Merged
merged 1 commit into from
Mar 30, 2024
Merged

Conversation

yungsters
Copy link
Contributor

Summary

Changes all unit tests that were spewing console output via console.log to no longer do so.

This will help reduce logspew and simplify parsing the reported Jest results.

How did you test this change?

See no more logspew when running unit tests.

$ yarn test

@react-sizebot
Copy link

react-sizebot commented Mar 29, 2024

Comparing: 2aed507...6584708

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.12 kB 177.12 kB = 55.06 kB 55.06 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 172.96 kB 172.96 kB = 53.92 kB 53.92 kB
facebook-www/ReactDOM-prod.classic.js = 592.70 kB 592.70 kB = 103.96 kB 103.96 kB
facebook-www/ReactDOM-prod.modern.js = 574.39 kB 574.39 kB = 100.99 kB 100.99 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 6584708

@kassens kassens requested a review from rickhanlonii March 29, 2024 20:48
@sebmarkbage
Copy link
Collaborator

Ideally we'd fix these tests to no longer log so that we can instead assert (maybe only in CI) that tests don't call console.log.

@yungsters
Copy link
Contributor Author

Agreed! But until then, I think this is incrementally better. (We already mock and suppress logs like this in other tests.)

@yungsters yungsters merged commit 9f835e6 into facebook:main Mar 30, 2024
38 checks passed
@yungsters yungsters deleted the shhh branch March 30, 2024 16:36
@rickhanlonii
Copy link
Member

Followup here: #28693

Two of these are specifically testing console.log behavior, but we can fix one of them to not use console.log.

rickhanlonii added a commit that referenced this pull request Apr 1, 2024
Followups to #28680

One of these test don't need to use `console.log`. 

The others are specifically testing `console.log` behavior, so I added a
comment.
@rickhanlonii
Copy link
Member

Followup to disallow unasserted console.log in CI here: #28708

rickhanlonii added a commit that referenced this pull request Apr 1, 2024
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.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Followups to facebook#28680

One of these test don't need to use `console.log`. 

The others are specifically testing `console.log` behavior, so I added a
comment.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants