Skip to content

Commit 96c8e74

Browse files
eps1lonrickhanlonii
authored andcommitted
Add Promise as a child test to Flight fixture (#28778)
1 parent 502bca5 commit 96c8e74

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

fixtures/flight/__tests__/__e2e__/smoke.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ test('smoke test', async ({page}) => {
1313
pageErrors.push(error.stack);
1414
});
1515
await page.goto('/');
16-
await expect(page.locator('h1')).toHaveText('Hello World');
16+
await expect(page.getByTestId('promise-as-a-child-test')).toHaveText(
17+
'Promise as a child hydrates without errors: deferred text'
18+
);
1719

1820
await expect(consoleErrors).toEqual([]);
1921
await expect(pageErrors).toEqual([]);

fixtures/flight/src/App.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import {like, greet, increment} from './actions.js';
1919

2020
import {getServerState} from './ServerState.js';
2121

22+
const promisedText = new Promise(resolve =>
23+
setTimeout(() => resolve('deferred text'), 100)
24+
);
25+
2226
export default async function App() {
2327
const res = await fetch('http://localhost:3001/todos');
2428
const todos = await res.json();
@@ -32,6 +36,11 @@ export default async function App() {
3236
<body>
3337
<Container>
3438
<h1>{getServerState()}</h1>
39+
<React.Suspense fallback={null}>
40+
<div data-testid="promise-as-a-child-test">
41+
Promise as a child hydrates without errors: {promisedText}
42+
</div>
43+
</React.Suspense>
3544
<Counter incrementAction={increment} />
3645
<Counter2 incrementAction={increment} />
3746
<Counter3 incrementAction={increment} />

0 commit comments

Comments
 (0)