---
title: CodeceptJS example with TestingBot
description: Run Automated WebDriver and Appium tests with CodeceptJS on a Cloud Selenium
  grid with real desktop browsers and physical mobile devices.
source_url:
  html: https://testingbot.com/support/web-automate/selenium/nodejs/codeceptjs
  md: https://testingbot.com/support/web-automate/selenium/nodejs/codeceptjs/index.md
---
# Getting started with CodeceptJS

[CodeceptJS](https://codecept.io/) is an end-to-end testing framework which supports Selenium, Appium, Playwright, Puppeteer and more.   
 It offers scenario driven testing, PageObjects support, beautiful reports and much more.

Let's start with installing everything we need:

    npm i --save-dev codeceptjs@3 webdriverio @codeceptjs/configure @wdio/testingbot-service@7

The TestingBot reporting/tunnel integration below uses CodeceptJS's built-in `wdio` plugin together with the `@wdio/testingbot-service` package. This requires **CodeceptJS 3** (the bundled `wdio` plugin was removed in CodeceptJS 4) and **`@wdio/testingbot-service` 7** (version 8+ is ESM-only and cannot be loaded by the plugin). The `webdriverio` package is required by the `WebDriver` helper.

Now we need to set up CodeceptJS. Please use the command below to initialize a new project:

    npx codeceptjs init

This will ask a bunch of questions, and will create a sample test at the end of the process.

## Example test

Now that you have everything set up, you can create a very simple test:

    Feature('My First Test');
    
    Scenario('test something', ({ I }) => {
      I.amOnPage('https://testingbot.com');
      I.see('TestingBot');
    });

This simple test will navigate to TestingBot and verify if the name TestingBot is present on the page.

Before we can run this test, we need to configure CodeceptJS to connect and run a browser on our grid.

## Configuration

You can configure CodeceptJS with a `codecept.conf.js` file:

    const { setHeadlessWhen } = require('@codeceptjs/configure');
    
    // turn on headless mode when running with HEADLESS=true environment variable
    // HEADLESS=true npx codecept run
    setHeadlessWhen(process.env.HEADLESS);
    
    exports.config = {
      tests: './*_test.js',
      output: './output',
      helpers: {
        WebDriver: {
          // 'url' is the base URL of the application under test (passed to I.amOnPage('/')).
          url: 'https://www.google.com',
          host: 'hub.testingbot.com',
          port: 443,
          protocol: 'https',
          path: '/wd/hub',
          browser: 'chrome',
          capabilities: {
            browserName: 'chrome',
            browserVersion: 'latest',
            platformName: 'WIN11',
            'tb:options': {
              build: 'CodeceptJS',
              key: 'YOUR KEY HERE',
              secret: 'YOUR SECRET HERE'
            }
          },
          smartWait: 5000,
          restart: false,
          timeouts: {
            script: 60000,
            'page load': 10000
          }
        }
      },
      include: {
        I: './steps_file.js'
      },
      bootstrap: null,
      mocha: {},
      name: 'codeceptjs-example',
      plugins: {
        retryFailedStep: {
          enabled: true
        },
        screenshotOnFail: {
          enabled: true
        },
        wdio: {
          enabled: true,
          services: ['testingbot'],
          user: 'YOUR KEY HERE',
          key: 'YOUR SECRET HERE'
        }
      }
    }

To run the test, you can do:

    npx codeceptjs run --steps

This will start the latest Chrome browser on TestingBot and run the test on our grid.   
 You will see a test appear in your member dashboard on TestingBot, together with a video, log files and other assets generated by the test.

## Specify Browsers & Devices

To run your existing tests on TestingBot, your tests will need to be configured to use the TestingBot remote machines. If the test was running on your local machine or network, you can simply change your existing test like this:

**Before**

    // codecept.conf.js
    exports.config = {
      tests: './*_test.js',
      output: './output',
      helpers: {
        WebDriver: {}
      }
    };

**After**

    // codecept.conf.js
    plugins: {
      ...
      wdio: {
        enabled: true,
        services: ['testingbot'],
        user: 'YOUR KEY HERE',
        key: 'YOUR SECRET HERE'
      }
    }

### Specifying the operating system, browser and version

To let TestingBot know on which browser/platform you want to run your test on, you need to specify the browsername, version, OS and other optional options in the capabilities field.

To see how to do this, please select a combination of browser, version and platform in the drop-down menus below.

  ![OS selected](https://testingbot.com/assets/environments/svg/windows11-0e1b28bc0fdd5034d3e4d3dc8d346c500a8c6522facf4b45d0da56537c1f1c6d.svg) Windows 11 › ![Browser Selected](https://testingbot.com/assets/environments/svg/chrome-c4081ff447d2d898d4afcb8f074a907c960e6f007716c1a1d119eee6803c4042.svg) Chrome 139 

Loading environments...

Please wait while we load the available browsers and platforms.

    

## Reporting Test Results

If you are using the [wdio-testingbot-service](https://webdriver.io/docs/testingbot-service/) then your tests will automatically report back meta-data to TestingBot (like test success, name, stacktrace, ...)

## Testing Internal Websites

We've built [TestingBot Tunnel](https://testingbot.com/support/tunnel), to provide you with a secure way to run tests against your staged/internal webapps.  
Please see our [TestingBot Tunnel documentation](https://testingbot.com/support/tunnel) for more information about this easy to use tunneling solution.

The example below shows how to easily run a CodeceptJS test with our Tunnel:

Adjust your `codecept.conf.js` configuration to use `tbTunnel: true`.   
 The [wdio-testingbot-service](https://webdriver.io/docs/testingbot-service/) will automatically download and use the tunnel for your tests.

**codecept.conf.js**

    plugins: {
      ...
      wdio: {
        enabled: true,
        services: ['testingbot'],
        user: 'YOUR KEY HERE',
        key: 'YOUR SECRET HERE',
        tbTunnel: true
      }
    }

## Run tests in Parallel

Please see [CodeceptJS parallel testing](https://codecept.io/parallel/#parallel-execution-by-workers) on how to run your tests in parallel.

You can specify the concurrency by specifying a number of workers:

    npx codeceptjs run-workers 2

or run multiple different browsers with:

    npx codeceptjs run-multiple --all

### Queuing

Every plan we provide comes with a limit of parallel tests.   
 If you exceed the number of parallel tests assigned to your account, TestingBot will queue the additional tests (for up to 6 minutes) and run the tests as soon as slots become available.

## Other Options

We offer many other [test options](https://testingbot.com/support/web-automate/selenium/test-options), for example: disable video recording, specifying a custom Firefox Profile, loading Chrome/Firefox/Safari extensions, running an executable before your test starts, uploading files, ...  
See our [list of test options](https://testingbot.com/support/web-automate/selenium/test-options) for a full list of options to customize your tests.

## Other NodeJS Framework examples

- [WebDriverIO](https://testingbot.com/support/web-automate/selenium/nodejs/webdriverio)

With WebDriverIO you can run Mocha, Jasmine and Cucumber tests.

- [CodeceptJS](https://testingbot.com/support/web-automate/selenium/nodejs/codeceptjs)

Run acceptance tests with CodeceptJS on TestingBot.

- [Protractor](https://testingbot.com/support/web-automate/selenium/nodejs/protractor)

Protractor is an end-to-end test framework for AngularJS applications. Protractor is a NodeJS program built on top of WebDriverJS.

- [Soda](https://testingbot.com/support/web-automate/selenium/nodejs/soda)

Selenium Node Adapter. A light-weight Selenium RC client for NodeJS.

- [Nightwatch](https://testingbot.com/support/web-automate/selenium/nodejs/nightwatch)

Nightwatch is an automated testing framework written in NodeJS.

- [WD.js](https://testingbot.com/support/web-automate/selenium/nodejs/wd)

WD.js is a NodeJS client for WebDriver/Selenium.

- [Hermione](https://testingbot.com/support/web-automate/selenium/nodejs/hermione)

Hermione is a Test Framework similar to WebDriverIO, with automatic test retries and plugins.

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
