mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add Promise as a child test to Flight fixture (#28778)
This commit is contained in:
@@ -13,7 +13,9 @@ test('smoke test', async ({page}) => {
|
||||
pageErrors.push(error.stack);
|
||||
});
|
||||
await page.goto('/');
|
||||
await expect(page.locator('h1')).toHaveText('Hello World');
|
||||
await expect(page.getByTestId('promise-as-a-child-test')).toHaveText(
|
||||
'Promise as a child hydrates without errors: deferred text'
|
||||
);
|
||||
|
||||
await expect(consoleErrors).toEqual([]);
|
||||
await expect(pageErrors).toEqual([]);
|
||||
|
||||
@@ -19,6 +19,10 @@ import {like, greet, increment} from './actions.js';
|
||||
|
||||
import {getServerState} from './ServerState.js';
|
||||
|
||||
const promisedText = new Promise(resolve =>
|
||||
setTimeout(() => resolve('deferred text'), 100)
|
||||
);
|
||||
|
||||
export default async function App() {
|
||||
const res = await fetch('http://localhost:3001/todos');
|
||||
const todos = await res.json();
|
||||
@@ -32,6 +36,11 @@ export default async function App() {
|
||||
<body>
|
||||
<Container>
|
||||
<h1>{getServerState()}</h1>
|
||||
<React.Suspense fallback={null}>
|
||||
<div data-testid="promise-as-a-child-test">
|
||||
Promise as a child hydrates without errors: {promisedText}
|
||||
</div>
|
||||
</React.Suspense>
|
||||
<Counter incrementAction={increment} />
|
||||
<Counter2 incrementAction={increment} />
|
||||
<Counter3 incrementAction={increment} />
|
||||
|
||||
Reference in New Issue
Block a user