DEV Community

Cover image for Running CodeceptJS in BrowserStack Automate
Alexander Lazaris
Alexander Lazaris

Posted on

4 1

Running CodeceptJS in BrowserStack Automate

Using a service like BrowserStack you can take your local automation tests to the skies. This is made possible by directing CodeceptJS to point to BrowserStack instead of running locally.

The BrowserStack service required is Automate, which runs tests using appium libraries on a plethora of mobile devices and operating systems. It also records tests by default, allowing you to review each scenario once complete.

Automate dashboard

To do so, you'll need to upload your mobile app. When successful, you'll receive an app_url in the response, which is the url to access the app in BrowserStack. This is how the devices provided by BrowserStack can access your application under test.

{
    "app_url": "bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3",
    "custom_id": "SampleApp",
    "shareable_id": "steve/SampleApp"
}
Enter fullscreen mode Exit fullscreen mode

Next, you'll need to modify codecept.conf.js to run the tests in BrowserStack. Ensure you store sensitive info in an .env file and access using dotenv.

  helpers: {
    Appium: {
      host: "hub-cloud.browserstack.com",
      port: 4444,
      user: process.env.BROWSERSTACK_USER,
      key: process.env.BROWSERSTACK_KEY,
      platform: "Android",
      app: process.env.BROWSERSTACK_APP_URL,
      desiredCapabilities: {
        realMobile: "true",
        device: "Samsung Galaxy S9",
        os_version: "8.0",
        networkLogs : "true",
      }
    }
  },
Enter fullscreen mode Exit fullscreen mode

The new properties needed are:

  • host : your browserstack host url
  • user : your browserstack username
  • key : your browserstack accesskey
  • app : your uploaded app url
  • desiredCapabilities : choose your device + appium settings. More can be found here

With this set, you're all good to go. No changes are need to your individual test files. When you're ready, run tests as you normally would and you'll see each test run tracked in the BrowserStack dashboard.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay