Skip to main content
Introducing the Automate SDK! Get your entire test suite running on BrowserStack in minutes! Learn More.

Run CodeceptJS + WebdriverIO Tests in Parallel

Run automated tests on multiple browsers in parallel with CodeceptJS + WebdriverIO using BrowserStack Automate.

Introduction

On BrowserStack, you can run multiple CodeceptJS tests at the same time across various browser, device, and OS combinations. This is called Parallel Testing. Parallel Testing gives you the same benefits as running a multi-threaded application.

With Parallel Testing, you can run the same test on different browser-device combinations, namely cross-browser testing, or run different tests on the same or different browser-device combinations. Parallel Testing helps you reduce the run time of your test suite, resulting in faster build times and faster releases.

In this guide, you will learn about:

  1. Prerequisites
  2. Running your first parallel test

Prerequisites

If you have already run your first test, you can skip the prerequisites.

Run sample test in parallel

Step 1: Clone the codecept-js-browserstack sample repo on GitHub using:

   git clone https://github.com/browserstack/codecept-js-browserstack
   cd codecept-js-browserstack

Step 2: Open the cloned project in the IDE of your choice and install the required dependencies by running the following command in your command line:

    npm install

Step 3: Set your BrowserStack credentials in the codecept-js-browserstack/src/test/parallel/codecept.conf.js file as follows:

parallel/codecept.conf.js
   require('dotenv').config()

    const BROWSERSTACK_USERNAME = process.env.BROWSERSTACK_USERNAME
    const BROWSERSTACK_ACCESS_KEY = process.env.BROWSERSTACK_ACCESS_KEY
    exports.config = {
        tests: './*_test.js',
        output: './output',
        helpers: {
            WebDriver: {
                url: 'https://bstackdemo.com',
                user: BROWSERSTACK_USERNAME,
                key: BROWSERSTACK_ACCESS_KEY,
                browser: 'chrome',
                desiredCapabilities: {}
            }
        },

Alternatively, you can set the environment variables in your system as shown below:

 # Set these values in your ~/.zprofile (zsh) or ~/.profile (bash)
   export BROWSERSTACK_USERNAME="YOUR_USERNAME"
   export BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY"
 # setx.exe does not set the environment variable in the current command prompt, but it will be available in subsequent command prompts
   setx BROWSERSTACK_USERNAME="YOUR_USERNAME"
   setx BROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY"

 # Verify whether the variables have been set
 echo BROWSERSTACK_USERNAME
 echo BROWSERSTACK_ACCESS_KEY

Note: It is recommended that you set the environment variables globally.

Step 4: Run your parallel test using the following command:

command prompt
   npm run parallel

Step 5: Optionally, you can also choose to run your tests on other environments by specifying them in the multiple key of the src/test/parallel/codecept.conf.js configuration file as follows:

parallel/codecept.conf.js
        multiple: {
            bstack: {
                browsers: [
                    {
                        browser: "Safari",
                        desiredCapabilities: {
                            "os": "OS X",
                            "os_version": "Catalina",
                            "project": "Codecept + WebdriverIO",
                            "build": "Parallel_Execution",
                            "name": "Parallel Test Safari",
                            "browserstack.debug": "true",
                            'browserstack.networkLogs': 'true',
                        },
                    },

                    {
                        browser: "Firefox",
                        desiredCapabilities: {
                            "os": "Windows",
                            "os_version": "10",
                            "project": "Codecept + WebdriverIO",
                            "build": "Parallel_Execution",
                            "name": "Parallel Test Firefox",
                            "browserstack.debug": "true",
                            'browserstack.networkLogs': 'true',
                        },
                    },
                ],
            },
        },

Step 6: View your tests on BrowserStack on the BrowserStack Automate Dashboard.

Next steps

After you have successfully run your first parallel test using BrowserStack, you can explore the following sections:

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
Talk to an Expert