diff --git a/apps/studio/src/ui/StudioWorkspace.test.tsx b/apps/studio/src/ui/StudioWorkspace.test.tsx index 7524f928..a42c9b9d 100644 --- a/apps/studio/src/ui/StudioWorkspace.test.tsx +++ b/apps/studio/src/ui/StudioWorkspace.test.tsx @@ -1647,7 +1647,7 @@ describe("StudioWorkspace", () => { expect(status.getByText("Draft saved")).toBeInTheDocument(); fireEvent.input(title, { target: { value: "Pods!" } }); expect(status.getByText("Saving the draft…")).toBeInTheDocument(); - expect(await status.findByText("Draft saved", {}, { timeout: 3000 })).toBeInTheDocument(); + expect(await status.findByText("Draft saved")).toBeInTheDocument(); expect(useCases.editReleaseDraft).toHaveBeenCalledTimes(1); }); @@ -1666,9 +1666,7 @@ describe("StudioWorkspace", () => { const title = await screen.findByRole("textbox", { name: "Title" }); await waitFor(() => expect(title).toBeEnabled()); fireEvent.input(title, { target: { value: "Pods!" } }); - expect( - await status.findByText("Last change not saved", {}, { timeout: 3000 }), - ).toBeInTheDocument(); + expect(await status.findByText("Last change not saved")).toBeInTheDocument(); }); it("keeps the cards' view in the URL, replacing the entry", async () => { diff --git a/docs/testing.md b/docs/testing.md index 35f28a79..92b62f42 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -1265,7 +1265,12 @@ runs every package's tests at once with coverage on, and takes some tests fifty times as long as a laptop does: the generator's check of `ns/` took over 5 s there, against 0.1 s. Tests that read a file at the size limits, about a second on a laptop, ran out of 30 s on a slow -runner. A test that hangs still fails. +runner. A test that hangs still fails. For the same reason, a +Testing Library query that waits (`findBy…`, `waitFor`) waits 10 s, +not its 1 s. The setting is in `packages/ui/src/test/setup.ts`, which +the Studio's and the web app's setup import. A screen whose button came +after a few reads of its data, about 0.1 s on a laptop, ran out of 1 s +in CI. ## Strategy per layer diff --git a/packages/ui/src/test/setup.ts b/packages/ui/src/test/setup.ts index dce584c2..6662ae4d 100644 --- a/packages/ui/src/test/setup.ts +++ b/packages/ui/src/test/setup.ts @@ -3,6 +3,7 @@ // SPDX-License-Identifier: MIT import "@testing-library/jest-dom/vitest"; +import { configure } from "@testing-library/preact"; import { LOCALES } from "@solid-memo/domain/locale"; import { loadLocale } from "../ui/i18n"; @@ -10,6 +11,14 @@ import { loadLocale } from "../ui/i18n"; // before it renders (apps/web/src/main.tsx), so a test speaks any of them. await Promise.all(LOCALES.map(loadLocale)); +// A findBy query or waitFor waits 10 s, not Testing Library's 1 s, for +// what it waits for, as a test may take 60 s, not vitest's 5 +// (vitest.shared.ts): CI takes some tests fifty times as long as a +// laptop does, and a screen that reads its data in a few steps, about +// 0.1 s on a laptop, ran out of the 1 s there. A query that never +// matches still fails, later. +configure({ asyncUtilTimeout: 10_000 }); + // happy-dom has no HTMLElement.translate. Browsers reflect it as the // translate="yes"/"no" attribute, which Preact sets as a property // (`translate={false}` on code from data), so the tests see the same.