-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
[Flight] Basic Integration Test #17307
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5e3e1e7:
|
}; | ||
} | ||
|
||
async function waitForDOMChange(container) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda wonky but I wanted to check for next mutation specifically rather than manually wait for models. Since React itself would wait for models and I want to test it waits correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn’t this what async act is for? Why isn’t it sufficient? It’s supposed to force flush even if it suspends and wait for nested promises.
What’s missing and can we fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol I forgot about it. Let me try it
OK this should work. I need two of them to flush Promise ticks for both client and server. |
ready for another |
// We can now show the sidebar. | ||
resolvePhotosModel(); | ||
await act(async () => { | ||
jest.runAllTimers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no timers in any of your test helpers so you don't need these calls.
I would put resolvePhotosModel
inside the act
call, even though it happens to work without it:
await act(async () => {
resolvePhotosModel();
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Node server uses setImmediate for scheduling. So I need at least one per server work request I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need a FlgihtServer.act(...) for that but let's run the timers for now.
packages/react-dom/src/__tests__/ReactFlightIntegration-test.js
Outdated
Show resolved
Hide resolved
packages/react-dom/src/__tests__/ReactFlightIntegration-test.js
Outdated
Show resolved
Hide resolved
packages/react-dom/src/__tests__/ReactFlightIntegration-test.js
Outdated
Show resolved
Hide resolved
packages/react-dom/src/__tests__/ReactFlightIntegration-test.js
Outdated
Show resolved
Hide resolved
I pushed an update that shims |
With act in CM, prod experimental build fails (?!) |
This adds a basic integration test where we actually feed the model to ReactDOM components and use Suspense. The test verifies that we can stream data and reveal more content as it happens. We also verify errors work.