Skip to main content

Command Line

Running tests​

npx mobilewright test

Run a single test file:

npx mobilewright test tests/login.test.ts

Run tests matching a title:

npx mobilewright test --grep "sign in"

Run tests from a specific project:

npx mobilewright test --project=ios

Options​

FlagDescription
-c, --config <file>Path to config file
--reporter <reporter>Reporter type: list, html, json
--grep <regex>Only run tests matching this pattern
--grep-invert <regex>Skip tests matching this pattern
--project <name...>Run tests from specific projects
--retries <count>Retry failed tests up to this many times
--timeout <ms>Test timeout in milliseconds
--workers <count>Number of concurrent workers
--pass-with-no-testsExit with code 0 when no tests are found
--listList all tests without running them

Show report​

Open the HTML test report from a previous run:

npx mobilewright show-report

Open a report from a specific directory:

npx mobilewright show-report ./my-report

By default, the report is served at localhost:9323. You can change the host and port:

npx mobilewright show-report --host 0.0.0.0 --port 8080

List devices​

List all connected devices, simulators, and emulators:

npx mobilewright devices

Take a screenshot​

Capture a screenshot of the current device screen:

npx mobilewright screenshot

Save to a specific file:

npx mobilewright screenshot -o home-screen.png

Target a specific device:

npx mobilewright screenshot -d <device-id>

Check environment​

Verify your environment is set up correctly for mobile development:

npx mobilewright doctor

Output as JSON for scripting:

npx mobilewright doctor --json

Check a specific category:

npx mobilewright doctor --category ios
npx mobilewright doctor --category android
npx mobilewright doctor --category system

Scaffold a project​

npm init mobilewright@latest

Prompts for TypeScript or JavaScript, the test directory (default tests), and the bundle ID of the app under test — pre-filling the bundle ID if it finds an Xcode or Gradle project nearby. It then writes package.json, mobilewright.config.ts and tests/example.spec.ts, and runs npm install.

See Installation for the generated files.