THE REPLACEQA BLOG

Why Playwright networkidle resolves immediately—and what to wait for

Understand networkidle, actionability and response waits, then choose readiness assertions that verify the customer outcome instead of adding sleeps.

page.waitForLoadState('networkidle') can resolve immediately when the current document has already reached that state. It is not a command to sleep for another 500 milliseconds. For a user journey, wait for the URL, control or rendered result that establishes the next step is ready.

That distinction answers a Reddit question about a trace showing a zero-millisecond networkidle wait. The question is about the method's meaning, not simply whether the method is fashionable. The API details here were checked on November 18, 2026.

Understand what the method observes

The Page API reference says a load-state wait resolves immediately if the current document already reached the requested state. It also requires the navigation to have committed. The networkidle state uses a period with no network connections and is discouraged for test readiness.

A click and a load-state check are not necessarily observing the same future document. A client-side route can update without a new document navigation at all. A page can also become quiet before its useful content is ready, or remain busy with background traffic after the relevant UI is usable.

So a short wait duration is not, by itself, a Playwright defect. Inspect the trace's navigation timeline and the resulting URL. Decide whether you intended to observe a document navigation, an API operation or a UI transition.

Pick the observation that proves readiness

Next action needs…Useful conditionWhat it does not establish
A destination routeExpected URL and route headingThat every background task finished
Search resultsExpected result identity and visible controlCorrectness of unrelated records
A saved editConfirmation plus persisted valueThat an optimistic toast alone is reliable
A request resultMatching method, path and response statusThat the browser rendered the result
A clickable controlLocator actionabilityThat clicking will meet the business requirement

Playwright's actionability checks already wait for conditions needed by locator actions. A successful click still needs an assertion afterward. It is possible to click the right button and reach the wrong customer outcome.

Express a search journey directly

This illustrative fragment belongs inside an existing Playwright test with a configured baseURL. The fictional catalog has a seeded “Weekly review” template. Adapt all routes, labels and fixture expectations together.

await page.goto('/catalog');
await page.getByRole('textbox', { name: 'Search', exact: true }).fill('weekly');
await page.getByRole('button', { name: 'Search', exact: true }).click();
const result = page.getByRole('link', { name: 'Weekly review', exact: true });
await expect(result).toBeVisible();
await result.click();
await expect(page).toHaveURL(/\/templates\/weekly-review$/);
await expect(page.getByRole('heading', { name: 'Weekly review', exact: true }))
  .toBeVisible();

There is no guessed delay. Each observation describes a requirement. The assertion documentation distinguishes retrying locator assertions from immediate value checks. expect(await locator.isVisible()).toBe(true) captures a boolean once; it does not give that boolean an opportunity to become true.

The runnable monitoring example develops the same search contract and shows how to preserve a failed run.

Wait for a response when it answers a separate question

If the test must verify the search request itself, register the response wait before triggering the request. For a hypothetical POST endpoint:

const responsePromise = page.waitForResponse(response =>
  new URL(response.url()).pathname === '/api/search' &&
  response.request().method() === 'POST'
);
await page.getByRole('button', { name: 'Search', exact: true }).click();
const response = await responsePromise;
expect(response.status()).toBe(200);
await expect(page.getByRole('link', { name: 'Weekly review', exact: true }))
  .toBeVisible();

Match the operation narrowly enough that another request cannot satisfy the wait. Do not add status() === 200 to the matching predicate if you want a 500 response to fail with a clear status assertion rather than eventually timing out. If the UI can legitimately use cached results without making a request, a mandatory response wait describes the wrong contract for that case.

Diagnose waits that still fail

Check whether the locator is unique, whether the expected record exists, and whether the application is stuck in an error state. A spinner that disappears because a request failed is not evidence that results are ready. Likewise, a heading left over from the previous route can satisfy a weak assertion.

For hydration bugs, an element may be visible before application event handlers are attached. Confirm that the application prevents premature interaction or exposes a real ready state. Adding arbitrary sleeps can make the defect less visible without improving the user experience.

Test the assertion against a controlled wrong result. Delay the response, return an empty list, or route to a different template in your test environment. The check should wait through the allowed delay and fail for the wrong outcome. Review dynamic-content assertions when values legitimately change, and keep navigation coverage separate from generic page-load timing.

Keep checking your important customer journeys.

Explore ReplaceQA ↗