# browserstack-node-sdk
Node SDK for browserstack selenium-webdriver tests

## Running Jest, Mocha and Cucumber tests in multiple platforms using SDK

### Add browserstack-node-sdk as a dev-dependency,

```
npm i -D browserstack-node-sdk
#or
yarn add --dev browserstack-node-sdk
```

### Setup

```
npx setup --username userName --key accessKey
```

  * Adds a browserstack.yml file at root of your project with your auth keys [BrowserStack Username and Access Key](https://www.browserstack.com/accounts/settings), browserstack configs and platforms.
  See sample config file [here](https://github.com/browserstack/jest-js-browserstack/blob/sdk/browserstack.yml)
  * Adds a new command for running tests on browserstack in scripts tag of package.json,

```
# before

"scripts": {
    # Jest tests
    "jest-test": "jest ...args",

    # Mocha tests
    "mocha-test": "mocha ...args",

    # Cucumber tests
    "cucumber-test": "cucumber-js ...args",

  },

# after

"scripts": {
    # Jest tests
    "jest-test": "jest ...args",
    "browserstack-jest-test": "browserstack-node-sdk jest ...args",

    # Mocha tests
    "mocha-test": "mocha ...args",
    "browserstack-mocha-test": "browserstack-node-sdk mocha ...args",

    # Cucumber tests
    "cucumber-test": "cucumber-js ...args",
    "browserstack-cucumber-test": "browserstack-node-sdk cucumber-js ...args"
  },

```

Run tests on browserstack by running
```
npm run browserstack-jest-test
# or
npm run browserstack-mocha-test
# or
npm run browserstack-cucumber-test

```

Sample test scripts are available in the [jest-js-browserstack](https://github.com/browserstack/jest-js-browserstack/tree/sdk), [mocha-browserstack](https://github.com/browserstack/mocha-browserstack/tree/sdk) & [cucumber-js-browserstack](https://github.com/browserstack/cucumber-js-browserstack/tree/sdk) repositories.
