-1

Using React and Ts, I am getting: Test timeout of 30000ms exceeded. Error: page._wrapApiCall: Test timeout of 30000ms exceeded when trying to mount with :

test("renders selected date", async ({ mount }) => {
  const ctx = makeMockCalendarContext({
    selectedDate: "2025-02-02",
  });

  const component = await mount(
    <MemoryRouter initialEntries={["/daily-graph"]}>
      <ContextWrapper ctx={ctx}>
        <HeaderComponent />
      </ContextWrapper>
    </MemoryRouter>
  );

  await expect(component.getByTestId("header-date")).toHaveText("2025-02-02");
});

The CT config is running but the Component being tested is not, and neither are the mocks. Can't get it.

I have tried isolating the problem with comments, rewriting everything over and over again and changing directories for the mocks. I simplified the problem by removing E2E config. I changed the mocks to make the mount simpler and tried different mount tests. Here is the Component Config file:

// playwright-ct.config.ts
import { defineConfig } from "@playwright/experimental-ct-react";
import path from "path";
import { fileURLToPath } from "url";

console.log("🔥 PLAYWRIGHT CT CONFIG LOADED");
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default defineConfig({
  testDir: "./tests-ct",

  use: {
    ctPort: 3100,

    ctViteConfig: {
      resolve: {
        alias: {
          // THESE MUST MATCH HEADERCOMPONENT IMPORTS EXACTLY
          "./hooks/useLogout":
            path.resolve(__dirname, "tests-ct/mocks.ts"),
          "./hooks/useMobileBreakpoint":
            path.resolve(__dirname, "tests-ct/mocks.ts"),
          "./logout/setupLogoutBroadcast":
            path.resolve(__dirname, "tests-ct/mocks.ts"),
        },
      },
    },
  },
});
4
  • We don't have <HeaderComponent />. Is that necessary to repro the issue? If so, please provide it. If not, please remove it or replace it with a trivial component. Ditto for the mocks--please provide all code necessary to repro this so it's easy to run the code, see the problem, and help. Thanks! Commented Dec 8 at 6:30
  • I also suggest sharing the full stack trace Commented Dec 8 at 6:41
  • Sorry for the late reply. I hired a tutor to help me go through it, and the issue was something that was just hard to catch, even with all the code available. Commented Dec 9 at 13:17
  • I don't follow, and that sounds like a bit of an unnecessary workaround. To help the community, I suggest clarifying your question fully so it's answerable, then adding your solution. Others can then potentially provide a more optimal solution. Thanks. Commented Dec 9 at 15:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.