{"id":20651806,"url":"https://github.com/saucelabs/node-saucelabs","last_synced_at":"2025-04-13T22:29:49.073Z","repository":{"id":3464660,"uuid":"4519039","full_name":"saucelabs/node-saucelabs","owner":"saucelabs","description":"A wrapper around Sauce Labs API","archived":false,"fork":false,"pushed_at":"2024-10-21T18:05:54.000Z","size":2813,"stargazers_count":93,"open_issues_count":17,"forks_count":44,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-10-29T17:44:05.762Z","etag":null,"topics":["api","api-client","hacktoberfest","rest","sauce-connect","sauce-labs","saucelabs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"pascalhahn/pirate-swd","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saucelabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-06-01T11:43:00.000Z","updated_at":"2024-09-03T10:40:01.000Z","dependencies_parsed_at":"2024-01-09T19:53:12.886Z","dependency_job_id":"626191fb-60c1-4031-ad36-44604b5d5954","html_url":"https://github.com/saucelabs/node-saucelabs","commit_stats":{"total_commits":330,"total_committers":34,"mean_commits":9.705882352941176,"dds":0.5272727272727273,"last_synced_commit":"9957e5434f69452725dbe77f3a500a54118a7b76"},"previous_names":[],"tags_count":102,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saucelabs%2Fnode-saucelabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saucelabs%2Fnode-saucelabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saucelabs%2Fnode-saucelabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saucelabs%2Fnode-saucelabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saucelabs","download_url":"https://codeload.github.com/saucelabs/node-saucelabs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790486,"owners_count":21162018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","hacktoberfest","rest","sauce-connect","sauce-labs","saucelabs"],"created_at":"2024-11-16T17:29:41.100Z","updated_at":"2025-04-13T22:29:49.020Z","avatar_url":"https://github.com/saucelabs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Sauce Labs [![Test Changes](https://github.com/saucelabs/node-saucelabs/actions/workflows/test.yml/badge.svg)](https://github.com/saucelabs/node-saucelabs/actions/workflows/test.yml)\n\nWrapper around all Sauce Labs REST APIs for [Node.js](http://nodejs.org/) (v18 or higher) including support for\n[Sauce Connect Proxy](https://docs.saucelabs.com/secure-connections/sauce-connect-5/) and TypeScript definitions.\n\n## Install\n\nTo install the package run:\n\n```sh\nnpm install saucelabs\n```\n\n## Options\n\n### user\n\nYour Sauce Labs username.\n\nType: `string`\nDefault: `process.env.SAUCE_USERNAME`\n\n### key\n\nYour Sauce Labs access key.\n\nType: `string`\nDefault: `process.env.SAUCE_ACCESS_KEY`\n\n### region\n\nYour Sauce Labs datacenter region. The following regions are available:\n\n- `us-west-1` (short `us`)\n- `eu-central-1` (short `eu`)\n- `us-east-4` (real mobile devices only)\n\nType: `string`\nDefault: `us`\n\n### proxy\n\nIf you want to tunnel your API request through a proxy please provide your proxy URL.\n\nType: `string`\nDefault: `null`\n\n### headers\n\nIf you want to set request headers, as example {'User-Agent': 'node-saucelabs'}\n\nType: `object`\u003cbr\u003e\nDefault: `{'User-Agent': 'saucelabs/\u003cVERSION\u003e (nodejs \u003cPLATFORM\u003e)'}`\n\n## Usage\n\nAll accessible API commands with descriptions can be found [here](docs/interface.md).\n\n### As CLI Tool\n\nThis package if installed globally can be used as CLI tool to access the API from the command line:\n\n```sh\n$ npm install -g saucelabs\n...\n$ sl listJobs $SAUCE_USERNAME 5 --region eu\n{ jobs:\n   [ { id: '19dab74f8fd848518f8d2c2cee3a6fbd' },\n     { id: 'dc08ca0c7fa14eee909a093d11567328' },\n     { id: '5bc6f70c777b4ae3bf7909a40f5ee41b' },\n     { id: 'f40fe7b044754eaaa5f5a130406549b5' },\n     { id: 'd1553f71f910402893f1e82a4dcb6ca6' } ] }\n```\n\nYou can find all available commands and options with description by calling:\n\n```sh\n$ sl --help\n# show description for specific command\n$ sl listJobs --help\n```\n\nor update the job status by calling:\n\n```sh\n$ sl updateJob cb-onboarding 690c5877710c422d8be4c622b40c747f \"{\\\"passed\\\":false}\"\n```\n\nor download a job asset:\n\n```sh\n$ sl downloadJobAsset 690c5877710c422d8be4c622b40c747f video.mp4 --filepath ./video.mp4\n```\n\nor upload a job asset:\n\n```sh\n$ sl uploadJobAssets 690c5877710c422d8be4c622b40c747f --files ./video.mp4 --files ./log.json\n```\n\nor start Sauce Connect Proxy in EU datacenter:\n\n```sh\n# start Sauce Connect tunnel for eu-central-1 region\n$ sl sc --region eu --tunnel-name \"my-tunnel\"\n# run a specific Sauce Connect version\n$ sl sc --scVersion 5.2.2\n# see all available Sauce Connect parameters via:\n$ sl sc --help\n```\n\nYou can see all available Sauce Connect parameters on the [Sauce Labs Docs](https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/).\n\n### As NPM Package\n\nThe following example shows how to access details of the last job you were running with your account that is being exposed as environment variables as `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY`. Alternatively you can pass the credentials via `options` to the constructor:\n\n```js\nimport SauceLabs from 'saucelabs';\n// if imports are not supported by your Node.js version, import the package as follows:\n// const SauceLabs = require('saucelabs').default;\n\n(async () =\u003e {\n  const myAccount = new SauceLabs();\n  // using constructor options\n  // const myAccount = new SauceLabs({ user: \"YOUR-USER\", key: \"YOUR-ACCESS-KEY\"});\n\n  // get full webdriver url from the client depending on region:\n  console.log(myAccount.webdriverEndpoint); // outputs \"https://ondemand.us-west-1.saucelabs.com/\"\n\n  // get job details of last run job\n  const jobs = await myAccount.listJobs(process.env.SAUCE_USERNAME, {\n    limit: 1,\n    full: true,\n  });\n\n  console.log(jobs);\n  /**\n     * outputs:\n     * { jobs:\n        [ { browser_short_version: '72',\n            video_url:\n             'https://assets.saucelabs.com/jobs/dc08ca0c7fa14eee909a093d11567328/video.flv',\n            creation_time: 1551711453,\n            'custom-data': null,\n            browser_version: '72.0.3626.81',\n            owner: '\u003cusername-redacted\u003e',\n            id: 'dc08ca0c7fa14eee909a093d11567328',\n            record_screenshots: true,\n            record_video: true,\n            build: null,\n            passed: null,\n            public: 'team',\n            end_time: 1551711471,\n            status: 'complete',\n            log_url:\n             'https://assets.saucelabs.com/jobs/dc08ca0c7fa14eee909a093d11567328/selenium-server.log',\n            start_time: 1551711454,\n            proxied: false,\n            modification_time: 1551711471,\n            tags: [],\n            name: null,\n            commands_not_successful: 1,\n            consolidated_status: 'complete',\n            manual: false,\n            assigned_tunnel_id: null,\n            error: null,\n            os: 'Windows 2008',\n            breakpointed: null,\n            browser: 'googlechrome' } ] }\n     */\n\n  /**\n   * start Sauce Connect Proxy\n   */\n  const sc = await myAccount.startSauceConnect({\n    /**\n     * you can pass in a `logger` method to print Sauce Connect log messages\n     */\n    logger: (stdout) =\u003e console.log(stdout),\n    /**\n     * see all available parameters here: https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/\n     * all parameters have to be applied camel cased instead of with hyphens, e.g.\n     * to apply the `--tunnel-name` parameter, set:\n     */\n    tunnelName: 'my-tunnel',\n  });\n\n  // run a test\n  // ...\n\n  // close Sauce Connect\n  await sc.close();\n\n  // upload additional log files and attach it to your Sauce job\n  await myAccount.uploadJobAssets('76e693dbe6ff4910abb0bc3d752a971e', [\n    // either pass in file names\n    './logs/video.mp4',\n    './logs/log.json',\n    // or file objects\n    {\n      filename: 'myCustomLogFile.json',\n      data: {\n        someLog: 'data',\n      },\n    },\n  ]);\n})();\n```\n\n\u003e You may wonder why `listJobs` requires a `username` as first parameter since you've already defined the process.env. The reason for this is that Sauce Labs supports a concept of Team Accounts, so-called sub-accounts, grouped together. As such functions like the mentioned could list jobs not only for the requesting account, but also for the individual team account. Learn more about it [here](https://docs.saucelabs.com/basics/acct-team-mgmt-hub/)\n\n### `webdriverEndpoint` property\n\nYou can use the `webdriverEndpoint` property of the client to get the full WebDriver endpoint to connect to Sauce Labs, e.g.:\n\n```js\nconst myAccount = new SauceLabs({\n  user: 'YOUR-USER',\n  key: 'YOUR-ACCESS-KEY',\n  region: 'eu', // run in EU datacenter\n  tunnelName: 'my-tunnel',\n});\n\n// get full webdriver url from the client depending on `region` option:\nconsole.log(myAccount.webdriverEndpoint);\n// outputs: \"https://ondemand.eu-central-1.saucelabs.com/\"\n```\n\n## Contributors\n\nThis module was originally created by [Dan Jenkins](https://github.com/danjenkins) with the help of multiple contributors ([Daniel Perez Alvarez](https://github.com/unindented), [Mathieu Sabourin](https://github.com/OniOni), [Michael J Feher](https://github.com/PhearZero), and many more). We would like to thank Dan and all contributors for their support and this beautiful module.\n\n## License\n\nCopyright 2012 Sauce Labs, Inc. Licensed Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaucelabs%2Fnode-saucelabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaucelabs%2Fnode-saucelabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaucelabs%2Fnode-saucelabs/lists"}