Skip to content

[Bug]: async react components #32184

Open
@sand4rt

Description

@sand4rt

Version

1.46.0

Steps to reproduce

  1. clone the repo: https://github.com/sand4rt/playwright-react-async-components
  2. run npm i
  3. run npm run test-ct

Expected behavior

Test should pass

Actual behavior

test fails

Additional context

React async components are commonly used in Next.js with the app router (surprisingly, this hasn't been reported yet). I've been quite busy lately, so i haven't had time to investigate, but this might be related to: #26308.

snippet:

export default async function Home() {
  const response = await fetch('https://playwright.dev/api');
  const data = await response.json();
  return <main>{data}</main>;
}
import Page from "./page";
import { expect, test } from "@playwright/experimental-ct-react";
import { Suspense } from "react";

test('suspense', async ({ page, mount }) => {
    page.route('https://playwright.dev/api', async (route) => {
        route.fulfill({ json: 'boop' });
    });
    const component = await mount(<Suspense><Page /></Suspense>);
    await expect(component).toContainText('boop'); // fails
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions