Testing React Component Hydration and Prerendering in facebook/react
This smoke test suite evaluates core React functionality using Playwright for end-to-end testing. It specifically focuses on promise handling, hydration, and prerendering behavior while monitoring console errors and page errors during test execution.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
facebook/react
fixtures/flight/__tests__/__e2e__/smoke.test.js
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([]);
});