Skip to main content

Timeouts

Mobilewright follows Playwright's timeout model. There are several independent timeout layers, each controlling a different part of the test lifecycle. All timeouts are in milliseconds.

Timeout overview​

TimeoutDefaultConfig locationDescription
Test timeout30 000timeoutLimits a single test (setup + body + teardown)
Global timeoutnoneglobalTimeoutCaps the entire test run
Action timeout5 000use.actionTimeoutLimits a single locator action (tap, fill, etc.)
Expect timeout5 000expect.timeoutLimits a single assertion (toBeVisible, toHaveText, etc.)
App launch timeout20 000use.appLaunchTimeoutLimits waiting for the app to reach the foreground
Install timeout60 000use.installTimeoutLimits app installation (installApps)
Allocation timeout15 minuse.allocationTimeoutLimits waiting for a device: queueing behind other workers plus cloud provisioning
Upload timeoutnonedriver.uploadTimeoutLimits test result upload (mobilenext only)

Test timeout​

A test fails if it does not complete within the test timeout. This includes the test body and beforeEach / afterEach hooks. Device setup (allocation, install, launch) runs on its own clocks — see the allocation, install and app launch timeouts below — so waiting for a cloud device never eats into the test's budget.

// mobilewright.config.ts
export default defineConfig({
timeout: 60_000, // 60 seconds
});

Override for a single test:

test('slow workflow', async ({ screen }) => {
test.setTimeout(120_000);
// ...
});

Extend the current timeout instead of replacing it (useful in beforeEach):

test.beforeEach(async ({}, testInfo) => {
testInfo.setTimeout(testInfo.timeout + 30_000);
});

Expect timeout​

Auto-retrying assertions poll until they pass or the expect timeout expires. Applies to toBeVisible, toHaveText, toBeEnabled, and all other expect() assertions.

export default defineConfig({
expect: {
timeout: 10_000,
},
});

Override for a single assertion:

await expect(screen.getByText('Order confirmed')).toBeVisible({ timeout: 15_000 });

Action timeout​

Limits individual locator actions: tap, fill, longPress, getText, isVisible, and so on. The action fails if the element is not found and actionable within this time.

export default defineConfig({
use: {
actionTimeout: 10_000,
},
});

Override for a single action:

await screen.getByRole('button', { name: 'Submit' }).tap({ timeout: 5_000 });

Global timeout​

Stops the entire test run after the given duration. Useful in CI to prevent a runaway test suite from consuming hours of build time. There is no default — omitting it means the run can take as long as it needs.

export default defineConfig({
globalTimeout: 30 * 60_000, // 30 minutes
});

App launch timeout​

Real devices can be significantly slower to launch apps than simulators. This timeout limits how long Mobilewright waits for the app to reach the foreground after launchApp() is called.

export default defineConfig({
use: {
appLaunchTimeout: 60_000, // 60 seconds for slow real devices
},
});

Install timeout​

When installApps is set, Mobilewright installs the app before each test run. Installation can be slow over USB or on cloud devices. Default: 60 seconds.

export default defineConfig({
use: {
installTimeout: 3 * 60_000, // 3 minutes
},
});

Allocation timeout​

Limits how long a worker waits for a device. This covers time spent queued behind other workers (for example when the account's concurrency is lower than workers) and cloud provisioning. It runs independently of the test timeout. Default: 15 minutes.

export default defineConfig({
use: {
allocationTimeout: 20 * 60_000, // 20 minutes
},
});

With the mobilenext driver, also raise driver.allocationTimeout (see below) when going above its 15-minute default.


Cloud device timeouts (mobilenext)​

These timeouts apply only when using the mobilenext driver.

Driver allocation timeout​

Bounds a single provisioning wait inside the fleet API (default 15 min). Normally use.allocationTimeout above is the one to set. The two run side by side and the shorter one wins, so if you raise use.allocationTimeout above 15 minutes, raise this one to match or the fleet call gives up first.

import { defineConfig } from 'mobilewright';
import { MobileNextDriver } from '@mobilewright/driver-mobilenext';

export default defineConfig({
driver: new MobileNextDriver({
apiKey: process.env.MOBILENEXT_API_KEY,
allocationTimeout: 15 * 60_000, // 15 minutes
}),
});

Upload timeout​

With the MobileNextDriver, the test report is uploaded to mobilenext.ai after the run — unless the testResult.uploadReport policy disables it ('off') or limits it to failed runs ('on-failure'); see Reporting. This timeout limits how long that upload may take.

import { defineConfig } from 'mobilewright';
import { MobileNextDriver } from '@mobilewright/driver-mobilenext';

export default defineConfig({
driver: new MobileNextDriver({
apiKey: process.env.MOBILENEXT_API_KEY,
uploadTimeout: 2 * 60_000, // 2 minutes
}),
});

Full example​

// mobilewright.config.ts
import { defineConfig } from 'mobilewright';
import { MobileNextDriver } from '@mobilewright/driver-mobilenext';

export default defineConfig({
timeout: 60_000,
globalTimeout: 30 * 60_000,

use: {
actionTimeout: 10_000,
appLaunchTimeout: 45_000,
installTimeout: 3 * 60_000,
},

expect: {
timeout: 10_000,
},

driver: new MobileNextDriver({
apiKey: process.env.MOBILENEXT_API_KEY,
allocationTimeout: 15 * 60_000,
uploadTimeout: 2 * 60_000,
}),
});