The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree
Skip to end of metadata
Go to start of metadata

Health Check


Table of Contents


The following repository:, allows you to quickly run simple automated tests in order to validate your NodeJS test environment with your account credentials. Below are the steps to configure your test environment and run a simple automated test.

For Demonstration Purposes Only!

The code in these scripts is provided on an "AS-IS" basis without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement. These scripts are provided for educational and demonstration purposes only, and should not be used in production. Issues regarding these scripts should be submitted through GitHub. These scripts are maintained by the Technical Services team at Sauce Labs.
Some examples in this repository, such as appium-examples and headless-examples, may require a different account tier beyond free trial. Please contact the Sauce Labs Sales Team for support and information.

Framework examples

Solution Outline

- [WebdriverIO with Appium (mobile browser tests)](./webdriverio/web/appium)
- [WebdriverIO examples](./webdriverio/web/examples)
    - [WebdriverIO and Sauce Connect](./webdriverio/web/examples/sc)
    - [WebdriverIO and extendedDebugging](./webdriverio/web/examples/extended-debugging)


In order to run this demo on your local machine, you must download, install, and configure the prerequisite software.

 Click here to view the prerequisite software installation guide

Install Git

Git is a version control system that lets you check out code from a repository, work with that code on your own branch, and then merge that code with any changes that have been made by other developers. Git is an essential tool for distributed development teams, and is a critical component of the continuous integration/continuous development toolchain.

  1. Go to
  2. Under Downloads, click Mac OS X.
  3. When the download completes, double-click the .dmg file open the installer package.
  4. Double-click the installer package to begin the installation.

    Security Warning

    You may see a warning message that the package can't be opened because it's not from a recognized developer. If this happens, go to System Preferences > Security and Privacy Settings, and click Open Anyway.

  5. Click Continue for the installation, and enter your local password to authorize the installation.
  1. Go to
  2. Under Downloads, click on Windows.
  3. When the dialog opens asking if you want to allow the app to make changes to your device, click Yes.
  4. Follow the steps in the setup wizard to complete the installation. You should accept all the default settings.

Install and NodeJS and NPM

You���ll need Node.js installed.

  • Install at least v12.16.1 or higher as this is the oldest active LTS version

If you don't have Node installed, we recommend installing NVM to assist managing multiple active Node.js versions.

If you don't want to install NVM, but the plain version of NodeJS please follow the following steps:


  1. Go to
  2. Under LTS, click Mac OS Installer X.
  3. When the download completes, double-click the .pkg file to open the installer
  4. Follow the prompts to complete the installation.


  1. Go to
  2. Under LTS, click Windows Installer.
  3. When the download completes, double-click the .msi file to open the installer
  4. Follow the prompts to complete the installation.

Install an IDE

It's recommended to install and Integrated Developer Environment, or a text editor, to help manage package dependencies, interperters, and overall code execution. There are several options available, some of them are free and some require payment:

  • Atom IDE free, IDE developed by GitHub.
  • WebStorm free trial, paid after 30 days, developed by JetBrains.
  • Komodo Edit, free, text editor, stripped down version of Komodo IDE (paid version).
  • Brackets free, text editor, contains a wealth of community plugins and extensions.

Use a Pre-built Workspace

If you want to skip the prerequisite setup, you can try this demo in a cloud-based IDE hosted by

  1. After the session launches, navigate to the terminal and use the following commands to export your Sauce Labs credentials:

    $ eval $(gp env -e SAUCE_USERNAME=******)
    $ eval $(gp env -e SAUCE_ACCESS_KEY=******)

    Note: If you start a new session or terminal in gitpod you have to re-apply environment variables. For more information consult the 
    gitpod documentation.

    $ eval $(gp env -e)

  2. Navigate to the desired test directory, for example:

    $ cd mocha-chai-tests
  3. Resolve the package dependencies and then run the test:

    $ npm install && npm test

Sauce Labs Test Setup

This example script follows the best practice of using environment variables in place of hardcoded authentication credentials. Once you've been able to successfully run the instant test with hardcoded credentials, you can use this test to make sure that you've correctly set up your environment variables for authentication.


In order to run these scripts you must complete the following prerequisite steps:

Try Demo in Gitpod

Select the button below to try this demo in Gitpod

Open in Gitpod

After the gitpod session launches, navigate to the terminal and run the following commands to save your Sauce Labs Credentials to gitpod as environment variables:

eval $(gp env -e SAUCE_USERNAME=******)
eval $(gp env -e SAUCE_ACCESS_KEY=******)

Click the following link if you're unsure how to access your Sauce Labs credentials. Also, if you start a new terminal in gitpod, you have to run the following command to reset envrionment variables:

eval $(gp env -e)

For more information consult the gitpod documentation

Run A Sample Test

  1. Clone the Repository and set your Sauce Labs Credentials:

    git clone
    export SAUCE_USERNAME=********
    export SAUCE_ACCESS_KEY=*******
  2. Please check all files in each framework example to see what you need to do to get the tests running.