Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Master this framework faster. Get optimization tips from elite testers. Join our DiscordJoin our Discord

Run cross-browser Puppeteer tests in parallel

A guide to running Puppeteer tests across multiple browser and OS combinations at the same time on BrowserStack.

Parallel Testing on BrowserStack lets you run the same test suite across multiple browser and OS combinations at the same time, reducing your total build time. The sample parallel_test.js file shows how to set this up.

Prerequisites

  • Clone the sample repository and set your credentials as described in the quickstart guide.

Run tests in parallel

Open parallel_test.js from the sample repository. The capabilities array defines every browser and OS combination you want to test on. Edit it to match your requirements:

const capabilities = [
  {
    'browser': 'chrome',
    'browser_version': 'latest',
    'os': 'osx',
    'os_version': 'catalina',
    'name': 'Chrome latest on Catalina',
    'build': 'puppeteer-build-2'
  },
  {
    'browser': 'firefox',
    'browser_version': 'latest',
    'os': 'osx',
    'os_version': 'catalina',
    'name': 'Firefox latest on Catalina',
    'build': 'puppeteer-build-2'
  },
  {
    'browser': 'edge',
    'browser_version': 'latest',
    'os': 'osx',
    'os_version': 'catalina',
    'name': 'Edge latest on Catalina',
    'build': 'puppeteer-build-2'
  },
  {
    'browser': 'chrome',
    'browser_version': 'latest-1',
    'os': 'Windows',
    'os_version': '10',
    'name': 'Chrome latest-1 on Win10',
    'build': 'puppeteer-build-2'
  },
  {
    'browser': 'firefox',
    'browser_version': 'latest-beta',
    'os': 'Windows',
    'os_version': '10',
    'name': 'Firefox beta on Win10',
    'build': 'puppeteer-build-2'
  },
  {
    'browser': 'edge',
    'browser_version': 'latest',
    'os': 'Windows',
    'os_version': '10',
    'name': 'Edge latest on Win10',
    'build': 'puppeteer-build-2'
  }
];

Each entry in the array runs as a separate parallel session on BrowserStack.

Run the parallel test. The script loops through the capabilities array and starts a session for each combination at the same time:

node parallel_test.js

After the run completes, view your results on the BrowserStack Automate dashboard.

Sample parallel test script

The script loops through the capabilities array and connects to BrowserStack in parallel for each entry. Your BrowserStack credentials are injected into each capability set from environment variables:

parallel_test.js
Copy icon Copy

Next steps

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