Registry / testing / saucelabs

saucelabs

JSON →
library0.0.0jsnpmunverified

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.

npm install saucelabs
INSTALL
IMPORT
SIG · SAUCELABS
S
saucelabs
testingjavascriptv0.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SauceLabs
✓ import SauceLabs from 'saucelabs';
✗ import { SauceLabs } from 'saucelabs';
The primary export is a default export, not a named export. This is the recommended import for ESM.
SauceLabs (CJS)
✓ const SauceLabs = require('saucelabs').default;
✗ const SauceLabs = require('saucelabs');
For CommonJS environments, due to the package's primary ESM export, the default export must be explicitly accessed.
SauceLabs (Type Import)
✓ import type SauceLabs from 'saucelabs';
While the package ships TypeScript types, the main client class is imported as a value. Use 'import type' if only referring to its type.

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.

import SauceLabs from 'saucelabs'; (async () => { // Ensure SAUCE_USERNAME and SAUCE_ACCESS_KEY are set as environment variables // or pass them directly as options: new SauceLabs({ user: 'YOUR_USER', key: 'YOUR_KEY' }) const myAccount = new SauceLabs(); try { // Get the full WebDriver endpoint URL for the configured region console.log(`WebDriver Endpoint: ${myAccount.webdriverEndpoint}`); // List the last 5 jobs for the authenticated user, including full details const jobs = await myAccount.listJobs(process.env.SAUCE_USERNAME ?? '', { limit: 5, full: true, }); if (jobs && jobs.jobs && jobs.jobs.length > 0) { console.log('Last 5 Jobs:'); jobs.jobs.forEach(job => { console.log(`- ID: ${job.id}, Name: ${job.name || 'N/A'}, Status: ${job.status || 'N/A'}`); }); } else { console.log('No jobs found for the user.'); } // Example of updating a job status (replace with a real job ID and data) // const jobIdToUpdate = jobs.jobs[0]?.id; // if (jobIdToUpdate) { // console.log(` Updating job ${jobIdToUpdate} status...`); // const updatedJob = await myAccount.updateJob( // process.env.SAUCE_USERNAME ?? '', // jobIdToUpdate, // { passed: true, name: 'My Updated Test' } // ); // console.log('Job updated:', updatedJob); // } } catch (error) { console.error('An error occurred:', error); process.exit(1); } })();
saucectl --version
Debug
Known issues
breakingVersion 8.0.0 removed the legacy Real Device Cloud (RDC) API endpoints. Applications relying on older RDC APIs must be refactored to use the current Real Device APIs to ensure compatibility.
fix
Review the Sauce Labs API documentation for the updated Real Device API endpoints and adjust your code accordingly. Legacy RDC methods will no longer function.
affects: >=8.0.0
breakingStarting with version 9.0.0, the package initially enforced a Node.js v18 or higher requirement. While Node.js 16 support was re-introduced in 9.0.2, developers on older Node.js versions (pre-16) will encounter compatibility issues.
fix
Upgrade your Node.js environment to v16 or higher. For new projects, Node.js v18 or later is recommended to ensure full compatibility and access to modern JavaScript features.
affects: >=9.0.0 <9.0.2
gotchaWhen using the package in a CommonJS (`require()`) environment, you must explicitly access the `default` export (`require('saucelabs').default`). A direct `require('saucelabs')` will not yield the expected client class instance.
fix
Change your import statement from `const SauceLabs = require('saucelabs');` to `const SauceLabs = require('saucelabs').default;`
affects: >=7.4.0
gotchaThe package defaults to authenticating via `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables. If these are not set, API calls will fail. Alternatively, credentials can be passed directly to the `SauceLabs` constructor.
fix
Ensure `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables are properly configured in your execution environment, or instantiate the client as `new SauceLabs({ user: 'YOUR_USERNAME', key: 'YOUR_ACCESS_KEY' });`
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: SauceLabs is not a constructor
Attempting to instantiate `SauceLabs` in a CommonJS module without accessing the `.default` export.
fix
Use `const SauceLabs = require('saucelabs').default;` instead of `const SauceLabs = require('saucelabs');`
Error: Credentials are not provided. Set SAUCE_USERNAME and SAUCE_ACCESS_KEY or pass them as options.
The SauceLabs client was instantiated without environment variables `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` set, and no credentials were passed in the constructor options.
fix
Set the `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables, or provide them explicitly: `new SauceLabs({ user: 'your_user', key: 'your_key' });`
RangeError: The 'options.url' property must be a string. Received type object
An API method was called with incorrect or malformed arguments, often related to regions or specific API parameters, leading to an invalid request URL.
fix
Verify the parameters passed to the API method against the `docs/interface.md` or Sauce Labs API documentation. Pay close attention to region strings and required object structures.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
saucelabs — npm install saucelabs · libregistry