Skip to main content
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Run your first test

Run your first Mobilewright test on BrowserStack App Automate real devices.

This page shows you how to point an existing Mobilewright test suite at BrowserStack App Automate using the @browserstack/mobilewright driver, and run it on a real device.

Onboard faster with Test Companion

Launch in your IDE. Chat with the AI assistant to configure and run your first build instantly.

Launch in IDE

Prerequisites

Before you begin, make sure you have:

  • An existing Mobilewright project (@mobilewright/test comes with your Mobilewright setup). Mobilewright version 0.0.53 or later.
  • BrowserStack Username and Access key, which you can find in your account profile. If you have not created an account yet, you can sign up for a Free Trial.

Install the BrowserStack driver

Install @browserstack/mobilewright into your existing Mobilewright project:

Terminal
Copy icon Copy

Set your credentials

Export your BrowserStack Username and Access key as environment variables:

Terminal
Copy icon Copy

Configure the driver

A BrowserStack run uses the same mobilewright.config.ts as any other Mobilewright project, alongside your usual testDir and bundleId settings. Import browserStackDriver from @browserstack/mobilewright and assign it to driver:

mobilewright.config.ts
Copy icon Copy

browserStackDriver() accepts:

  • app: the build under test. Give it a bs:// URL from a previous upload, a filesystem path to a local .apk or .ipa, or a public https:// URL. A local file is packaged and sent to BrowserStack the first time a run needs it, not on every run. If you omit app here, the driver falls back to the BROWSERSTACK_APP environment variable.
  • project: a name that groups this run’s sessions together on the App Automate dashboard.
  • username and accessKey: only needed here if you’d rather not rely on the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables you set earlier.

Device selection itself still uses Mobilewright’s regular config fields: deviceName matches a device name against a regex pattern, osVersion accepts a range expression such as ">=17 <19", and deviceType is always real for App Automate.

The rest of the file is standard Mobilewright test-runner configuration, unrelated to the driver. See the Mobilewright configurations reference for the config file resolution order, testMatch, timeout, reporter, and the use and expect blocks.

Run your test

Terminal
Copy icon Copy

A local .apk or .ipa referenced by your config is packaged and uploaded the first time a BrowserStack run needs it. When the driver is BrowserStack’s, Mobilewright also skips the mid-session app reinstall step it normally performs between local test runs.

A few other flags come in handy once you’re past your first run:

Terminal
Copy icon Copy

View test results

You don’t need to configure a reporter to get a named, labeled session. BrowserStack names each session after the tests it contained and marks it passed or failed once the run finishes, printing a dashboard link to your terminal output. Open the App Automate dashboard directly to browse a session’s video, device logs, and network logs.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle