mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Prerendering in flight is similar to prerendering in Fizz. Instead of receiving a result (the stream) immediately a promise is returned which resolves to the stream when the prerender is complete. The promise will reject if the flight render fatally errors otherwise it will resolve when the render is completed or is aborted.
30 lines
893 B
JavaScript
30 lines
893 B
JavaScript
import {test, expect} from '@playwright/test';
|
|
|
|
test('smoke test', async ({page}) => {
|
|
const consoleErrors = [];
|
|
page.on('console', msg => {
|
|
const type = msg.type();
|
|
if (type === 'warn' || type === 'error') {
|
|
consoleErrors.push({type: type, text: msg.text()});
|
|
}
|
|
});
|
|
const pageErrors = [];
|
|
page.on('pageerror', error => {
|
|
pageErrors.push(error.stack);
|
|
});
|
|
await page.goto('/');
|
|
await expect(page.getByTestId('promise-as-a-child-test')).toHaveText(
|
|
'Promise as a child hydrates without errors: deferred text'
|
|
);
|
|
await expect(page.getByTestId('prerendered')).not.toBeAttached();
|
|
|
|
await expect(consoleErrors).toEqual([]);
|
|
await expect(pageErrors).toEqual([]);
|
|
|
|
await page.goto('/prerender');
|
|
await expect(page.getByTestId('prerendered')).toBeAttached();
|
|
|
|
await expect(consoleErrors).toEqual([]);
|
|
await expect(pageErrors).toEqual([]);
|
|
});
|