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

Remove RTR from ReactSuspense-test #28390

Merged
merged 2 commits into from
Feb 20, 2024
Merged

Conversation

jackpope
Copy link
Contributor

Summary

Cleaning up internal usage of ReactTestRenderer

How did you test this change?

yarn test packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 20, 2024

await resolveText('Tab: 0');
await waitForPaint(['Tab: 0']);
expect(root).toMatchRenderedOutput('Tab: 0 + sibling');
assertLog(['Tab: 0']);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any concerns with the waitForPaint calls moving to sync assertLog for legacy render tests? The text resolution already completes and populates scheduler logger when using ReactDOM.render as oppose to ReactTestRenderer.create() but I'm not sure of the reason.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah makes sense

@react-sizebot
Copy link

react-sizebot commented Feb 20, 2024

Comparing: a515d75...794dc0c

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.85 kB 176.85 kB = 55.14 kB 55.14 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 178.85 kB 178.85 kB = 55.72 kB 55.71 kB
facebook-www/ReactDOM-prod.classic.js = 591.91 kB 591.91 kB = 104.47 kB 104.47 kB
facebook-www/ReactDOM-prod.modern.js = 575.20 kB 575.20 kB = 101.47 kB 101.47 kB
test_utils/ReactAllWarnings.js Deleted 66.90 kB 0.00 kB Deleted 16.40 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 66.90 kB 0.00 kB Deleted 16.40 kB 0.00 kB

Generated by 🚫 dangerJS against 794dc0c

@@ -136,19 +141,20 @@ describe('ReactSuspense', () => {
'Suspend! [A]',
'Loading...',
]);
expect(root).toMatchRenderedOutput(null);
expect(container.textContent).toEqual('');
Copy link
Member

Choose a reason for hiding this comment

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

why is this empty and not null?

Copy link
Member

Choose a reason for hiding this comment

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

textContent is always a string

document.createElement('div').textContent // ""

);
await waitForAll(['Initial']);
expect(root).toMatchRenderedOutput('Initial');
assertLog(['Initial']);
Copy link
Member

Choose a reason for hiding this comment

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

It's fine to use the waitForAll, it's basically a shortcut for act + assertLog.


// This update will suspend.
root.update(<App shouldSuspend={true} step={1} />);
await act(() => {
Copy link
Member

Choose a reason for hiding this comment

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

act will flush everything, but the waitFor only flushes up to a certain log. I would expect flushing everything here to break something, since the point of this test is to partially flush, then schedule an update.

// React has a heuristic to batch all updates that occur within the same
// event. This is a trick to circumvent that heuristic.
ReactTestRenderer.create('whatever');
await act(() => {
Copy link
Member

Choose a reason for hiding this comment

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

It might not be correct for the interrupt to flush, see the comment above that this is a trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah still working on this one as it failed in the production build when the gating was applied. Trying to figure out how to recreate the interrupt trick without RTR


await resolveText('Tab: 0');
await waitForPaint(['Tab: 0']);
expect(root).toMatchRenderedOutput('Tab: 0 + sibling');
assertLog(['Tab: 0']);
Copy link
Member

Choose a reason for hiding this comment

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

Yeah makes sense

@jackpope jackpope merged commit 90a0ae1 into facebook:main Feb 20, 2024
36 checks passed
@jackpope jackpope deleted the remove-rtr-usage-6 branch February 20, 2024 20:40
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js`
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
## Summary

Cleaning up internal usage of ReactTestRenderer

## How did you test this change?

`yarn test
packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js`

DiffTrain build for commit 90a0ae1.
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.

5 participants