{"library":"saucelabs","title":"Sauce Labs Node.js API Client","description":"This package provides a comprehensive wrapper around the Sauce Labs REST APIs, enabling programmatic interaction with Sauce Labs services from Node.js environments. It includes support for accessing job details, managing assets, and integrating with Sauce Connect Proxy (v5). The current stable version is 9.0.2, with releases occurring as new features or maintenance fixes are required, typically in response to Sauce Labs API updates or critical bug fixes. Key differentiators include built-in TypeScript definitions, a convenient command-line interface (CLI) for common tasks, and robust support for various Sauce Labs data centers. It is designed for Node.js v16 or higher, though v18+ is recommended, making it suitable for modern JavaScript and TypeScript projects that need to automate testing workflows on the Sauce Labs platform.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install saucelabs"],"cli":{"name":"saucectl","version":null}},"imports":["import SauceLabs from 'saucelabs';","const SauceLabs = require('saucelabs').default;","import type SauceLabs from 'saucelabs';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import SauceLabs from 'saucelabs';\n\n(async () => {\n  // Ensure SAUCE_USERNAME and SAUCE_ACCESS_KEY are set as environment variables\n  // or pass them directly as options: new SauceLabs({ user: 'YOUR_USER', key: 'YOUR_KEY' })\n  const myAccount = new SauceLabs();\n\n  try {\n    // Get the full WebDriver endpoint URL for the configured region\n    console.log(`WebDriver Endpoint: ${myAccount.webdriverEndpoint}`);\n\n    // List the last 5 jobs for the authenticated user, including full details\n    const jobs = await myAccount.listJobs(process.env.SAUCE_USERNAME ?? '', {\n      limit: 5,\n      full: true,\n    });\n\n    if (jobs && jobs.jobs && jobs.jobs.length > 0) {\n      console.log('Last 5 Jobs:');\n      jobs.jobs.forEach(job => {\n        console.log(`- ID: ${job.id}, Name: ${job.name || 'N/A'}, Status: ${job.status || 'N/A'}`);\n      });\n    } else {\n      console.log('No jobs found for the user.');\n    }\n\n    // Example of updating a job status (replace with a real job ID and data)\n    // const jobIdToUpdate = jobs.jobs[0]?.id;\n    // if (jobIdToUpdate) {\n    //   console.log(`\nUpdating job ${jobIdToUpdate} status...`);\n    //   const updatedJob = await myAccount.updateJob(\n    //     process.env.SAUCE_USERNAME ?? '',\n    //     jobIdToUpdate,\n    //     { passed: true, name: 'My Updated Test' }\n    //   );\n    //   console.log('Job updated:', updatedJob);\n    // }\n\n  } catch (error) {\n    console.error('An error occurred:', error);\n    process.exit(1);\n  }\n})();","lang":"typescript","description":"This quickstart initializes the Sauce Labs client, retrieves and logs the WebDriver endpoint, and then fetches details for the last five jobs associated with the authenticated user. It demonstrates basic API interaction and handling credentials.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}