Back to Knowledge Hub
Getting Started

Playwright Test Timeout: Which Budget Expired?

Read a Playwright timeout error to identify whether the test, expectation, action or hook budget expired before changing configuration.

BotBrowser Team

Playwright Test Timeout: Which Budget Expired?
Documentation

Want the structured docs for Getting Started?

This article lives in the editorial library. For step-by-step setup, reference material, and ongoing updates, jump into the docs section.

A Playwright test timeout needs a budget owner before it needs a larger number. Four deliberately failing test files produced four terminal messages from one controlled configuration: the test budget reported a 2500-millisecond test timeout, an expectation reported a 500-millisecond assertion timeout, a click reported its own 500-millisecond action timeout, and a hanging beforeEach reported the outer 2500-millisecond test budget. BotBrowser supplies a controlled browser environment, but it does not decide which Playwright Test budget expired or which wait belongs to the application.

TL;DR

  • The message form identifies the layer: test timeout, expectation output, locator.click TimeoutError, or a named hook.
  • The configured duration in the error is stronger evidence than total elapsed job time.
  • The action call log names what it was retrying, such as a disabled button.
  • A beforeEach failure can be reported by the outer test budget even though the message names the hook.
  • Fix the condition the successful path needs before increasing the budget that happened to notice it.

Contents

Read the owning budget from the error

The first useful distinction is between a runner-level limit and a Playwright operation that emitted TimeoutError. Playwright Test documents a test-level timeout that interrupts a test, while assertion and action timeouts are budgets inside the test. A beforeEach hook runs inside the outer test budget. After the test body, afterEach and fixture teardown share another test-timeout budget; beforeAll and afterAll use the same configured value on a separately timed hook budget. The name in the error is the first locator for the owner; the call log supplies the next.

The exact wording matters because similarly shaped timeouts lead to different repairs. A bare test timeout tells you the test body used its whole allowance, but not which asynchronous condition was missing. An expectation failure includes the locator, expected value, received value and assertion budget. An action timeout includes the operation and the actionability checks it repeated. A hook timeout names the hook context. For beforeEach, that context is inside the test body's budget; the other hook phases follow the budget boundaries above.

When a shard finishes with a timeout, preserve the shard identifier with the terminal error before merging reports. A bare process exit can hide that only one shard lacked a test result. Use the Playwright sharding and report merge workflow to keep the failed shard's blob and reconcile the expected tests.

Do not use total test duration as a substitute for the configured budget. The local expectation case had a 500-millisecond assertion timeout but its whole result took 1208 milliseconds. The action case had a 500-millisecond click timeout but its result took 1223 milliseconds. Setup, error rendering and framework bookkeeping belong to the reported job, not to the inner budget named in the error. Read both numbers and keep their scopes separate.

The fixture used 2500 milliseconds for the test, 500 through the expectation configuration, and an explicit 500 in the action. The hook file uses only the supported test.beforeEach(fn) form, so it makes no claim about an unsupported per-hook timeout setting. Its terminal message still comes from the outer test budget.

Use a clean error artifact. The raw JSON records each case's status, duration and error. When the specific failure provides them, errorLocation and the call log also identify the source line and operation. A console screenshot preserves how a human reads the failure, but it may wrap or colorize the text.

Finally, do not change all four budgets after finding one. Timeouts can compete: extending the test budget may hide which inner operation is stuck, while extending an inner assertion may still leave the outer test limit to terminate the run. Record the owner, the observed condition and the smallest scope that can be changed before editing configuration.

The distinction also matters for retry behavior. A retry reruns a test; it does not identify which budget expired in the previous attempt. If the retry is configured and its report keeps only the last status, the first error can disappear. Preserve each attempt's terminal message and configured budget. The retry attribution model explains how to keep retries from erasing the diagnostic evidence.

A budget can be deliberately short and still be correct. The fixture expects every case to fail. In a real suite, a short assertion might reveal that an initialization signal never arrived, while a long test budget only determines how long the runner waits. The assertion's failure is useful because it identifies the missing condition; the test budget's failure is less specific because it can wrap any awaited operation that does not end.

The same syntax can appear in different ownership scopes. A TimeoutError from a locator action references that action's budget. A text assertion failure that reports a 500-millisecond timeout references the expectation budget. A runner message beginning Test timeout of references the test budget. A message that appends while running "beforeEach" hook establishes hook context without turning the hook into a separate default budget. Sort the message shape before looking for a configuration knob.

One configuration, four terminal failures

The owned fixture runs four cases in one Playwright Test 1.58.0 project on stock Chrome 157.0.8103.79. Each case is in its own test file, fullyParallel is true, and the result metadata records four actual workers. The four case start times span 16 milliseconds. The complete run took 9732.836 milliseconds. Wall duration is harness evidence, not a timeout recommendation.

Four terminal messages map to test, expect, action and hook budgets with observed result durations of 2502, 1208, 1223 and 2501 milliseconds.

Observed messageOwnerConfigured budgetResult durationTerminal status
Test timeout ... exceeded.test body2500 units2502 unitstimedOut
Timeout: ... near toHaveTextexpectation500 units1208 unitsfailed
locator.click: Timeout ... exceeded.action500 units1223 unitsfailed
... while running "beforeEach" hook.hook context under outer test budget2500 units2501 unitstimedOut

The parallel metadata and start times establish that this is not an accidental serial loop. They do not make the four measured wall times a performance benchmark. The stable evidence is the budget owner, terminal message and operation; scheduling can still change the whole result duration.

Use one failing layer per experiment. The fixture does not put an action inside a failing expectation and then ask which budget ran out first. Such nesting makes the result depend on the order of competing deadlines. Isolate the missing condition, record the outside test budget, and only then add another layer if production behavior genuinely requires it.

A parallel run is appropriate because the task is four independent browser cases in four files and the required pool is four. The result records actualWorkers: 4, and the first starts differ by only 16 milliseconds. The published source retains the config, raw result and expected failure count. It does not infer a performance benchmark from 9732.836 milliseconds.

The fixture's deliberate failures should remain expected. The state is not stored in a flaky rework queue because the failures are the evidence. Keep the expected status and the terminal artifact in the test record. If the goal is a green suite, wrap each isolated reproduction in an assertion about the error, rather than changing the production test to tolerate every timeout.

That positive assertion should check the stable part of the message, not ANSI color sequences or the full dynamic stack. The test case, configured budget and operation are enough to declare ownership. A broader match on the word timeout alone would accept the wrong layer and destroy the lookup's value.

Test budget: no actionable API error

A timeout is not the only failure that looks like another one: the Playwright self signed certificate diagnosis shows one error string covering three different certificate faults and how reading the received certificate separates them.

The first case waits for a timer that lasts much longer than the test budget. It produces a terminal Test timeout ... exceeded. at 2502 milliseconds. The error does not name a locator, an assertion or a click. That lack is information: the runner interrupted at the test boundary without a Playwright API emitting a more specific timeout.

The body in this case has no Playwright operation, so increasing a page action timeout would not address it. The next step is to inspect what the body awaited and whether that operation has a test-level wait. If it is an application-owned promise, use an observable condition with its own timeout and attach a useful message; if the whole scenario truly needs more time, raise the test budget deliberately and record why.

A test timeout is also the outer ceiling for inner waits. If an assertion is configured for 5000 milliseconds but the test has 2500 milliseconds, the test budget can terminate first. Compare the budgets before declaring the assertion defective. The Playwright timeouts guide states the relationship between test and hook timeouts, while the assertions guide covers automatic retries for web assertions.

Network silence is a separate readiness signal. If the missing condition is a UI state after an open background request, compare it with networkidle and application readiness before attributing the terminal runner budget to network speed.

The test budget should not be a generic repair for a missing signal. A bare increase changes how long the runner waits before doing what it already did at the old deadline. The diagnostic question is which condition never became true. Record the awaited action, the application state at the start and whether any inner operation emitted its own error.

Expectation budget: expected and received are part of the evidence

The second case sets a <p> element to pending and calls toHaveText('ready'). The message names locator #state, expected "ready", received "pending" and a 500-millisecond Timeout field. The raw call log records 4 × locator resolved to <p id="state">pending</p> before failure. Those facts separate a wrong expected state from a locator that never resolved.

An expectation timeout does not prove the page is still processing. The element is present and stable; its text is simply different. Increasing the assertion budget would give the application more time to change it, but only if the page has an asynchronous transition that eventually produces ready. The correct repair is to identify the event that owns that transition and wait for the real outcome.

Web assertions keep checking the condition until it matches or the assertion budget ends. They are different from a fixed sleep and different from asserting once against a snapshot. Read the call log to see whether the locator resolved and what value it saw. If the locator never resolves, the missing element is the narrower question; if it resolves with the wrong value, the expected result or application state is the narrower question.

Expectation output is also better evidence than a generic test timeout. It gives you both sides of the comparison at the budget boundary. Keep that expected-and-received pair in the failure record, because a later retry may produce a different value and could hide the original mismatch.

Action budget: the call log names the blocked check

The third case clicks a disabled button with an explicit 500-millisecond action timeout. The result begins TimeoutError: locator.click and reports the same configured budget. The call log says locator resolved to <button disabled>Save</button> and repeats element is not enabled while retrying the action.

This is an action budget even though the message contains TimeoutError. The specific method is locator.click, and the retry log names the actionability condition that never passed. Increasing the test-level timeout would give the same disabled button more time, but it would not establish that the button is waiting for a relevant application state.

A missing or hidden element would produce a different part of the call log. Here the click can resolve the locator and inspect it, but the control remains disabled. A useful repair checks the application path that enables the button. If the disabled state is intentional, test that state instead of forcing a click.

Action budgets also compete with the test and expectation scopes. Keep an explicit action timeout when the interaction has a meaningful bound, then make sure the outer test budget leaves room for all the actions and assertions the scenario needs. Playwright's actionability documentation supplies the API contract; BotBrowser setup does not.

For an unreproducible action failure, retain the complete action call log. The first failing check and the retry timings disclose which condition the runner was evaluating. A truncated message such as "timed out" loses the difference between a missing locator and a disabled control.

Hook budget: the outer test limit still owns the run

The fourth case lives in its own file and uses only test.beforeEach(fn). Its hook waits longer than the test budget. The terminal message names Test timeout ... exceeded while running "beforeEach" hook. It names the hook context, but the configured duration is still the outer 2500-millisecond test budget. This result is about beforeEach; it does not move teardown or suite hooks under the same clock.

The experiment shows why "set a hook timeout" is not a complete lookup. The text names the hook and the numeric value names the test budget. If a suite intentionally gives a hook separate time, confirm which supported API and scope its version provides, then reproduce the outcome. The fixture avoids inventing an unsupported options argument.

Hook failures are especially likely to hide shared setup. The browser context lifecycle explains how setup creates and closes isolated state. If a hook hangs in context creation, authentication or fixture teardown, the hook name narrows the code path. It does not prove the application is slow.

Keep hook timeout evidence alongside the test budget. Record whether the hook started, what it awaited and whether the test body ran. A runner may close the worker before the test body receives control. The trace debugging article covers preserving the execution history when the default output is insufficient.

Worker variation is a separate hypothesis. Four parallel failures with stable outcomes do not show that worker count caused the problem; they only show that the experiment was not serialized. If a timeout appears only when workers increase, compare CPU pressure, shared test data and external services before changing the runner limits. The retry and environment evidence should live beside the error, not only in a later incident report.

External services need their own observation. A local timer or a deliberately disabled button creates a reproducible error on this machine. A slow checkout, DNS answer or third-party API can occupy the same runner budget without becoming reproducible during a local rerun. Record the request or service call, its timeout and the result that arrived. The browser configuration controls the client environment, not the remote service's deadline.

Trace and video settings can explain what happened without changing the timeout. A trace may show that an action waited on the same disabled state, or that the test body never reached the action. Keep the trace scoped to the failing attempt so its timestamps can be compared with the terminal error. A trace that starts after the first failure is not evidence of that failure.

BotBrowser allows its executable and profile to be launched under Playwright control, but it does not decide which runner budget expired and does not guarantee that an external service responds before a test timeout.

The expectation failure below is the clearest short example: the reduced record keeps its expected and received values, while the native JSON retains the longer polling log behind them.

Received: "pending"

FAQ

Is every Playwright timeout a TimeoutError?

No. A runner-level test timeout can appear as a timed-out test result without a Playwright API throwing TimeoutError. Expectation failures have their own structure, and an action timeout contains TimeoutError with the operation and call log.

Should I increase the test timeout first?

Only after finding what the test was waiting for. If an assertion or action has its own error, the outer test budget may merely be a ceiling. Changing it without reading the inner owner can make the suite slower while leaving the missing condition unchanged.

Does beforeEach have its own default timeout?

Do not infer one from the name in the message. The hook ran inside the outer test budget here. Check the documented hook API and scope for the runner version, and use its supported timeout mechanism when separate time is intentional.

Can a retry tell me which budget expired?

It can if every attempt preserves its own error and duration. A retry by itself only reruns the test. A report that keeps only the final pass can erase the first budget's evidence.

Sources

Practical conclusion

Read the error before changing a timeout. A bare Test timeout of ... points at the test budget; expectation output with expected, received and a duration points at the assertion budget; a locator.click error with its call log points at the action budget; and a Test timeout while running a beforeEach hook points at that test's outer budget. Do not infer another hook phase's budget from its name. afterEach and fixture teardown use the same configured value in a shared timeout after the test, while beforeAll and afterAll use it on separately timed hook budgets. Keep the configured duration, observed job duration, first failing condition and every retry artifact separate. Fix the missing application condition first, then choose the smallest budget that belongs to the failing layer.

#Playwright#Test Timeout#Assertions#Test Debugging

This article is part of the guide: Browser Automation Getting Started: A First Run Map

Run the same check in BotBrowser

Load a profile, keep the signals you just read about consistent inside the browser, and confirm the result on your own machine before a rollout.