Skip to main content

Configuration

Mobilewright is configured through a mobilewright.config.ts file at the root of your project. Wrap the object in defineConfig for type-checking and editor autocomplete.

import { defineConfig } from 'mobilewright';

export default defineConfig({
platform: 'ios',
bundleId: 'com.example.myapp',
deviceName: /iPhone/,
timeout: 30_000,
});

Config file resolution

When you run mobilewright test, it looks for these files in the current directory, in order:

  1. mobilewright.config.ts
  2. mobilewright.config.js
  3. mobilewright.config.mjs

Pass --config <path> to point at a specific file instead. If no config is found, Mobilewright runs with defaults.

Device and app

Which device to run on and which app to drive.

OptionTypeDefaultDescription
platform'ios' | 'android'Target platform
deviceIdstringSpecific device identifier (local drivers only)
deviceNameRegExpMatch a device by name, e.g. /iPhone 17/
bundleIdstringApp bundle ID to launch
installAppsstring | string[]App paths (APK/IPA) to install before launching
autoAppLaunchbooleantrueLaunch the app automatically after connecting

Driver

The driver decides where tests run — a local device via mobilecli, or a cloud device.

OptionTypeDefaultDescription
driverDriverConfig{ type: 'mobilecli' }Which driver to use (see below)
urlstringmobilecli server URL (for a remote server)
mobilecliPathstringPath to the mobilecli binary if it's not on PATH
autoStartbooleantrueAuto-start the mobilecli server if it isn't running

Local (mobilecli):

driver: { type: 'mobilecli' }

Cloud (Mobile Next):

driver: {
type: 'mobilenext',
apiKey: process.env.MOBILENEXT_API_KEY,
region: 'us',
allocationTimeout: 300_000, // wait for a cloud device, ms (default: 5 min)
uploadTimeout: 60_000, // upload test results, ms (default: none)
}

With the mobilenext driver, test results are uploaded to mobilenext.ai automatically unless you set testResult: { uploadReport: 'off' }.

Test runner

How tests are discovered and executed.

OptionTypeDefaultDescription
testDirstringconfig file dirDirectory to search for tests
testMatchstring | RegExp | Array**/*.{test,spec}.{js,ts,mjs}Glob patterns for test files
testIgnorestring | RegExp | ArrayPatterns to skip during discovery
outputDirstringtest-resultsDirectory for test artifacts
timeoutnumberPer-test timeout in ms
globalTimeoutnumberHard cap on the entire suite run in ms
retriesnumberMax retries for flaky tests — see Retries
workersnumber | string1Concurrent workers — see Parallelism
fullyParallelbooleanfalseRun all tests in parallel
forbidOnlybooleanFail the run if test.only is present (useful in CI)
reporter'list' | 'html' | 'json' | 'junit' | ArrayReporter(s) to use
globalSetupstring | string[]File(s) run once before all tests
globalTeardownstring | string[]File(s) run once after all tests
projectsProjectConfig[]Multi-device / multi-platform matrix — see Projects

Timeouts and per-action defaults

use sets defaults applied to every test. expect sets the default assertion timeout. Both can be overridden per project and per call.

export default defineConfig({
use: {
actionTimeout: 5_000, // tap, fill, etc. — default 5000
appLaunchTimeout: 20_000, // wait for app foreground — default 20000
installTimeout: 120_000, // installApps — default none
animations: 'off', // system animations: 'on' | 'off'
},
expect: {
timeout: 5_000, // toBeVisible, toHaveText, etc. — default 5000
},
});

See Timeouts for how these interact and how to override them at call sites.

Reporting

OptionTypeDefaultDescription
viewTree'on-failure' | 'off''off'Attach the accessibility tree as JSON to the report; 'on-failure' attaches only on failing tests
captureGitInfo{ commit?: boolean; diff?: boolean }Capture git commit info into report metadata

Per-project overrides

Everything that varies by device belongs in projects. Each project has a use block that overrides the top-level settings for that run.

export default defineConfig({
bundleId: 'com.example.myapp',
projects: [
{ name: 'iOS', use: { platform: 'ios', deviceName: /iPhone/ } },
{ name: 'Android', use: { platform: 'android', deviceName: /Pixel/ } },
],
});

The project use block accepts platform, deviceName, bundleId, installApps, animations, actionTimeout, appLaunchTimeout, and installTimeout. Projects can also override timeout, testDir, testMatch, testIgnore, outputDir, retries, grep, grepInvert, and declare dependencies on other projects. See Projects for the full matrix.