Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
saucelabs
Advanced tools
The 'saucelabs' npm package provides a Node.js client for interacting with the Sauce Labs API. Sauce Labs is a cloud-based platform for automated testing of web and mobile applications. This package allows you to manage Sauce Labs resources, such as jobs, tunnels, and assets, programmatically.
Managing Jobs
This feature allows you to manage and retrieve details about your Sauce Labs jobs. The code sample demonstrates how to get details of a specific job using its job ID.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function getJobDetails(jobId) {
const job = await saucelabs.getJob(jobId);
console.log(job);
}
getJobDetails('your-job-id');
Managing Tunnels
This feature allows you to manage Sauce Connect tunnels. The code sample demonstrates how to list all active tunnels.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function getTunnels() {
const tunnels = await saucelabs.listTunnels();
console.log(tunnels);
}
getTunnels();
Uploading Assets
This feature allows you to upload assets to a specific job. The code sample demonstrates how to upload a file to a job using its job ID.
const { SauceLabs } = require('saucelabs');
const saucelabs = new SauceLabs({ user: 'your-username', key: 'your-access-key' });
async function uploadAsset(jobId, filePath) {
const response = await saucelabs.uploadJobAssets(jobId, { files: [filePath] });
console.log(response);
}
uploadAsset('your-job-id', 'path/to/your/file');
WebdriverIO is a popular testing utility for Node.js that provides a high-level API for browser automation. It supports multiple browser drivers and services, including Sauce Labs. Compared to the 'saucelabs' package, WebdriverIO offers a more comprehensive solution for writing and running tests, while 'saucelabs' focuses on managing Sauce Labs resources.
Selenium WebDriver is a widely-used tool for browser automation. It provides bindings for multiple programming languages, including JavaScript. While Selenium WebDriver can be used with Sauce Labs for running tests on their cloud infrastructure, it does not provide the same level of resource management capabilities as the 'saucelabs' package.
Cypress is an end-to-end testing framework that aims to make testing fast, easy, and reliable. It provides a rich API for writing tests and a powerful test runner. While Cypress does not natively integrate with Sauce Labs, it can be configured to run tests on Sauce Labs infrastructure. Compared to 'saucelabs', Cypress focuses more on the testing experience and less on resource management.
Wrapper around the Sauce Labs REST APIs for Node.js (v8 or higher).
To install the package run:
npm install saucelabs
Your Sauce Labs username.
Type: string
Default: process.env.SAUCE_USERNAME
Your Sauce Labs access key.
Type: string
Default: process.env.SAUCE_ACCESS_KEY
Your Sauce Labs datacenter region. The following regions are available:
us-west-1
(short us
)eu-central-1
(short eu
)Type: string
Default: us
If set to true you are accessing the headless Sauce instances (this discards the region
option).
Type: boolean
Default: false
All accessible API commands with descriptions can be found here. In order to route requests through a proxy set HTTP_PROXY
, HTTPS_PROXY
or NO_PROXY
as environment variable. For more information on this, read here.
This package if installed globally can be used as CLI tool to access the API from the command line:
$ npm install -g saucelabs
...
$ sl listJobs $SAUCE_USERNAME --limit 5 --region eu
{ jobs:
[ { id: '19dab74f8fd848518f8d2c2cee3a6fbd' },
{ id: 'dc08ca0c7fa14eee909a093d11567328' },
{ id: '5bc6f70c777b4ae3bf7909a40f5ee41b' },
{ id: 'f40fe7b044754eaaa5f5a130406549b5' },
{ id: 'd1553f71f910402893f1e82a4dcb6ca6' } ] }
You can find all available commands and options with description by calling:
sl --help
# show description for specific command
sl listJobs --help
The 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
.
import SauceLabs from 'saucelabs';
(async () => {
const myAccount = new SauceLabs();
// get job details of last run job
const job = await user.listJobs(
process.env.SAUCE_USERNAME,
{ limit: 1, full: true }
);
console.log(job);
/**
* outputs:
* { jobs:
[ { browser_short_version: '72',
video_url:
'https://assets.saucelabs.com/jobs/dc08ca0c7fa14eee909a093d11567328/video.flv',
creation_time: 1551711453,
'custom-data': null,
browser_version: '72.0.3626.81',
owner: '<username-redacted>',
id: 'dc08ca0c7fa14eee909a093d11567328',
record_screenshots: true,
record_video: true,
build: null,
passed: null,
public: 'team',
end_time: 1551711471,
status: 'complete',
log_url:
'https://assets.saucelabs.com/jobs/dc08ca0c7fa14eee909a093d11567328/selenium-server.log',
start_time: 1551711454,
proxied: false,
modification_time: 1551711471,
tags: [],
name: null,
commands_not_successful: 1,
consolidated_status: 'complete',
manual: false,
assigned_tunnel_id: null,
error: null,
os: 'Windows 2008',
breakpointed: null,
browser: 'googlechrome' } ] }
*/
})
To run the test suite, first invoke the following command within the repo, installing the development dependencies:
npm install
Then run the tests:
npm test
This module was originally created by Dan Jenkins with the help of multiple contributors (Daniel Perez Alvarez, Mathieu Sabourin, Michael J Feher, and many more). We would like to thank Dan and all contributors for their support and this beautiful module.
FAQs
A wrapper around Sauce Labs REST API
The npm package saucelabs receives a total of 685,603 weekly downloads. As such, saucelabs popularity was classified as popular.
We found that saucelabs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.