Sauce Labs

Sauce labs is a cloud provider. It requires a monthly or yearly subscription, but offers free plans for open source projects.

Start by signing up for an account at saucelabs.com, then set the following environment variables:

SAUCE_USERNAME
Your sauce labs username.
SAUCE_ACCESS_KEY
Your sauce labs access key.

To do this locally, you can create a .env file in your project's root directory:

SAUCE_USERNAME={your sauce username}
SAUCE_ACCESS_KEY={your sauce access key}

Then you can test using code like:

import assert from 'assert';
import cabbie from 'cabbie-sync';

// connect to saucelabs, adding {debug: true} makes cabbie log each method call.
const driver = cabbie('saucelabs', {debug: true});

try {
  // navigate to a url in the currently active window
  driver.activeWindow.navigateTo('http://example.com');

  // get an element, and check that its text equals some expected value
  assert.equal(
    driver.activeWindow.getElement('h1').getText(),
    'Example Domain',
  );
} finally {
  // whether tests pass or fail, dispose of the driver
  driver.dispose();
}