# tw-saucelabs-connector

> Helps connect the local machine to SauceLabs and start a remote browser.

Latest version **1.0.1** (published 2020-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install tw-saucelabs-connector
pnpm add tw-saucelabs-connector
yarn add tw-saucelabs-connector
bun add tw-saucelabs-connector
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-10 |
| First published | 2020-06-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 24 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alexander Moskovkin |
| Maintainers | ekarudianto |

## Links

- npm: https://www.npmjs.com/package/tw-saucelabs-connector
- Repository: https://github.com/AlexanderMoskovkin/saucelabs-connector
- Homepage: https://github.com/AlexanderMoskovkin/saucelabs-connector/
- Issues: https://github.com/AlexanderMoskovkin/saucelabs-connector/issues
- npm.io page: https://npm.io/package/tw-saucelabs-connector

## Dependencies (9)

- [wd](https://npm.io/package/wd.md) ^1.2.0
- [pify](https://npm.io/package/pify.md) ^2.3.0
- [lodash](https://npm.io/package/lodash.md) ^4.13.1
- [pinkie](https://npm.io/package/pinkie.md) ^2.0.4
- [request](https://npm.io/package/request.md) ^2.67.0
- [os-family](https://npm.io/package/os-family.md) ^1.0.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^5.8.20
- [read-file-relative](https://npm.io/package/read-file-relative.md) ^1.2.0
- [sauce-connect-launcher](https://npm.io/package/sauce-connect-launcher.md) ^1.2.5

## Recent versions

- 1.0.1 (latest) — 2020-06-10

## README

# saucelabs-connector

Helps connect the local machine to SauceLabs and start a remote browser. The reason that this repo is exist is to acommodate saucelabs and testcafe integration behind proxy, the previous implementation doesn't contain proxy setting for connecting to saucelabs REST API and for tunnel connection.

## Install

`$ npm install @otr/saucelabs-connector`

## Publishing the package

`$ npm run publish` will build the library and publish it to @otr nexus registry

## Development note

Please make sure to use node version 10.x to develop this plugin

## Usage
```js

var SauceLabsConnector = require('saucelabs-connector');

// Use this online tool to generate a valid platform configuration: 
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
var browserInfo = {
    platform:    'Windows 10',
    browserName: 'chrome',
    version:     '45.0'
};

var pageUrl    = 'www.example.com';
var jobTimeout = 60; // in seconds
var jobOptions = {
    jobName: 'Sample tests',
    build:   'build-1234',
    tags:    ['tag1', 'tag2', 'tag3']
};

var saucelabsConnector = new SauceLabsConnector('SAUCELABS_USERNAME', 'SAUCELABS_ACCESS_KEY');
var saucelabsBrowser   = null;

// Connects the local machine to SauceLabs
saucelabsConnector
    .connect()
    .then(function () {
        // Use the waitForFreeMachines method to ensure that the required number of machines is available.
        var machineCount    = 3;     // the required number of machines.
        var requestInterval = 30000; // the request delay in milliseconds.
        var maxAttemptCount = 5;     // the maximum number of attempts.
        
        return saucelabsConnector.waitForFreeMachines(machineCount, requestInterval, maxAttemptCount);
    })
    .then(function () {
        // Starts a remote browser on SauceLabs with the specified url.
        // jobOptions and jobTimeout are optional arguments.
        return saucelabsConnector.startBrowser(browserInfo, pageUrl, jobOptions, jobTimeout);
    })
    .then(function (browser) {
        saucelabsBrowser = browser;
        // Do some work with the browser
    })
    .then(function () {
        // Closes the browser
        return saucelabsConnector.stopBrowser(saucelabsBrowser);
    })
    .then(function () {
        return saucelabsConnector.disconnect();
    });
```

## Additional Configuration

You can select the data center you want to connect to, by setting the environment variable `SAUCE_API_HOST` 
to the respective data center's host: 

```bash
export SAUCE_API_HOST=saucelabs.com # for us-west-1, default
export SAUCE_API_HOST=eu-central-1.saucelabs.com # for eu-central-1
```

---
_Source: https://npm.io/package/tw-saucelabs-connector · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
