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

fix(pretty-format): Handle empty string children in React same as react-test-renderer #14470

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Sep 5, 2023

Summary

I tried to upgrade the entire repo to React 18 (for #14463), and it turns out react-test-renderer@18 has a change in how it handles empty string children. Which is fine, but aligning is a breaking change in Jest.

Test plan

Adjusted the test

@SimenB SimenB added this to the Jest 30 milestone Sep 5, 2023
@netlify
Copy link

netlify bot commented Sep 5, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 84bf63a
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/650982e4bd79130008198e99
😎 Deploy Preview https://deploy-preview-14470--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -21,7 +21,7 @@ const getChildren = (arg: unknown, children: Array<unknown> = []) => {
arg.forEach(item => {
getChildren(item, children);
});
} else if (arg != null && arg !== false) {
} else if (arg != null && arg !== false && arg !== '') {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the breaking change

assertPrintedJSX(
React.createElement('Mouse', null, ''),
'<Mouse>\n \n</Mouse>',
);
assertPrintedJSX(React.createElement('Mouse', null, ''), '<Mouse />');
Copy link
Member Author

Choose a reason for hiding this comment

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

this shows the change that will show up in people's snapshots

@SimenB SimenB force-pushed the align-pretty-format-and-test-renderer-single-string-child branch from 6350ca8 to f0fefae Compare September 8, 2023 08:26
@SimenB SimenB enabled auto-merge (squash) September 19, 2023 08:19
@SimenB SimenB merged commit 149383e into jestjs:main Sep 19, 2023
4 of 9 checks passed
@SimenB SimenB deleted the align-pretty-format-and-test-renderer-single-string-child branch September 19, 2023 11:16
@SimenB
Copy link
Member Author

SimenB commented Sep 19, 2023

I missed this made the tests time out on circle ci... 1a96a5c fixes it

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant