How to use saucelabs - 10 common examples

To help you get started, we’ve selected a few saucelabs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webex / react-widgets / test / journeys / lib / test-helpers / index.js View on Github external
return new Promise((resolve, reject) => {
    const build = process.env.BUILD_NUMBER;
    const account = new SauceLabs({
      username: process.env.SAUCE_USERNAME,
      password: process.env.SAUCE_ACCESS_KEY
    });
    const browserName = process.env.BROWSER || 'chrome';
    const platform = process.env.PLATFORM || 'mac 10.12';

    account.getJobs((err, jobs) => {
      // Something terrible has happened if we cannot get jobs from sauce
      if (err) {
        reject(err);
      }
      const widgetJobs = jobs.filter((job) => job.build === build && job.name && job.name.includes(name) && job.status === 'in progress'
              && job.os.toLowerCase().includes(platform) && job.browser.toLowerCase().includes(browserName));

      resolve(widgetJobs);
    });
github bookbrainz / bookbrainz-site / test / custom_commands / customSauceEnd.js View on Github external
export function command() {
	const saucelabs = new SauceLabs({
		password: process.env.SAUCE_ACCESS_KEY,
		username: process.env.SAUCE_USERNAME
	});

	const sessionid = this.capabilities['webdriver.remote.sessionid'];
	const jobName = this.currentTest.name;

	saucelabs.updateJob(sessionid, {
		name: jobName,
		passed: this.currentTest.results.failed === 0
	}, () => {
		// empty
	});

	this.end();
}
github saucelabs / speedo / src / commands / run.js View on Github external
yargs.showHelp()
        // eslint-disable-next-line no-console
        console.error(ERROR_MISSING_CREDENTIALS)
        return process.exit(1)
    }

    const status = ora(`Start performance test run with user ${username} on page ${config.site}...`).start()

    const logDir = config.logDir
        ? path.resolve(process.cwd(), config.logDir)
        : tmp.dirSync().name

    /**
     * check if job already exists
     */
    const user = new SauceLabs({
        user: username,
        key: accessKey,
        region: config.region
    })

    /**
     * find if job already exists
     */
    let job = null
    try {
        job = await user.listJobs(
            username,
            { name: jobName, limit: 10 }
        )
        status.succeed()
    } catch (e) {
github saucelabs / speedo / src / commands / analyze.js View on Github external
const accessKey = argv.key || process.env.SAUCE_ACCESS_KEY
    const config = getConfig(argv)
    const budget = config ? config.budget : null
    const metrics = budget ? getBudgetMetrics(budget) : getMetricParams(argv, budget)

    /**
     * check if username and access key are available
     */
    if (!username || !accessKey) {
        yargs.showHelp()
        // eslint-disable-next-line no-console
        console.error(ERROR_MISSING_CREDENTIALS)
        return process.exit(1)
    }

    const user = new SauceLabs({
        user: username,
        key: accessKey,
        region: argv.region
    })

    const status = ora(`Fetch job "${argv.jobName}" from ${username}`).start()

    /**
     * fetch job
     */
    let job
    try {
        const { jobs } = await waitFor(
            () => user.listJobs(
                username,
                { name: argv.jobName, limit: 1 }
github thetribeio / node-react-starter-kit / features / support / hooks.js View on Github external
After(async function ({ pickle: { name }, result: { status } }) {
    if (!this.local) {
        const sauceApi = new SauceLabs({ user: SAUCELABS_USER, key: SAUCELABS_KEY });
        // eslint-disable-next-line no-underscore-dangle
        const jobId = (await this.driver.getSession()).id_;
        const passed = 'passed' === status;
        sauceApi.updateJob(SAUCELABS_USER, jobId, {
            name: `${this.browser} - ${name}`,
            passed,
        });
        if (!passed) {
            console.info(`Failed test video: https://app.saucelabs.com/tests/${jobId}`);
        }
    }
    this.driver.quit();
});
github chialab / rna-cli / commands / unit / action.js View on Github external
module.exports = async function unit(app, options = {}) {
    let cwd = process.cwd();
    // check sauce values
    if (options.saucelabs) {
        if (options['saucelabs.username']) {
            process.env.SAUCE_USERNAME = options['saucelabs.username'];
        }
        if (options['saucelabs.key']) {
            process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
        }
        if (!process.env.SAUCE_USERNAME) {
            throw 'Missing SAUCE_USERNAME variable.';
        }
        if (!process.env.SAUCE_ACCESS_KEY) {
            throw 'Missing SAUCE_ACCESS_KEY variable.';
        }
    }

    // Handle Karma custom context file option
    const customContextFile = options['context'];

    if (!process.env.hasOwnProperty('NODE_ENV')) {
        // Set NODE_ENV environment variable.
        app.log(colors.yellow('🔍 setting "test" environment.'));
        process.env.NODE_ENV = 'test';
github chialab / rna-cli / commands / unit / action.js View on Github external
module.exports = async function unit(app, options = {}) {
    let cwd = process.cwd();
    // check sauce values
    if (options.saucelabs) {
        if (options['saucelabs.username']) {
            process.env.SAUCE_USERNAME = options['saucelabs.username'];
        }
        if (options['saucelabs.key']) {
            process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
        }
        if (!process.env.SAUCE_USERNAME) {
            throw 'Missing SAUCE_USERNAME variable.';
        }
        if (!process.env.SAUCE_ACCESS_KEY) {
            throw 'Missing SAUCE_ACCESS_KEY variable.';
        }
    }

    // Handle Karma custom context file option
    const customContextFile = options['context'];

    if (!process.env.hasOwnProperty('NODE_ENV')) {
        // Set NODE_ENV environment variable.
        app.log(colors.yellow('🔍 setting "test" environment.'));
github chialab / rna-cli / commands / unit / action.js View on Github external
module.exports = async function unit(app, options = {}) {
    let cwd = process.cwd();
    // check sauce values
    if (options.saucelabs) {
        if (options['saucelabs.username']) {
            process.env.SAUCE_USERNAME = options['saucelabs.username'];
        }
        if (options['saucelabs.key']) {
            process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
        }
        if (!process.env.SAUCE_USERNAME) {
            throw 'Missing SAUCE_USERNAME variable.';
        }
        if (!process.env.SAUCE_ACCESS_KEY) {
            throw 'Missing SAUCE_ACCESS_KEY variable.';
        }
    }

    // Handle Karma custom context file option
    const customContextFile = options['context'];
github chialab / rna-cli / commands / unit / action.js View on Github external
module.exports = async function unit(app, options = {}) {
    let cwd = process.cwd();
    // check sauce values
    if (options.saucelabs) {
        if (options['saucelabs.username']) {
            process.env.SAUCE_USERNAME = options['saucelabs.username'];
        }
        if (options['saucelabs.key']) {
            process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
        }
        if (!process.env.SAUCE_USERNAME) {
            throw 'Missing SAUCE_USERNAME variable.';
        }
        if (!process.env.SAUCE_ACCESS_KEY) {
            throw 'Missing SAUCE_ACCESS_KEY variable.';
        }
    }

    // Handle Karma custom context file option
    const customContextFile = options['context'];

    if (!process.env.hasOwnProperty('NODE_ENV')) {
github chialab / rna-cli / commands / e2e / action.js View on Github external
config.test_settings.default.screenshots.path = config.test_settings.default.screenshots.path || 'reports/e2e/screenshots';
                        }
                    } else {
                        // option.screenshots is false
                        config.test_settings.default.screenshots = { enabled: false };
                    }
                }
            }
            let sauceConnectProcess;
            if (options.saucelabs) {
                // check sauce values
                if (options['saucelabs.username']) {
                    process.env.SAUCE_USERNAME = options['saucelabs.username'];
                }
                if (options['saucelabs.key']) {
                    process.env.SAUCE_ACCESS_KEY = options['saucelabs.key'];
                }
                if (!process.env.SAUCE_USERNAME) {
                    app.log(colors.red('Missing SAUCE_USERNAME variable.'));
                    app.log(colors.grey('export a `SAUCE_USERNAME` environment variable or use the `--saucelabs.username` flag.'));
                    return global.Promise.reject();
                }
                if (!process.env.SAUCE_ACCESS_KEY) {
                    app.log(colors.red('Missing SAUCE_ACCESS_KEY variable.'));
                    app.log(colors.grey('export a `SAUCE_ACCESS_KEY` environment variable or use the `--saucelabs.key` flag.'));
                    return global.Promise.reject();
                }
                promise = promise.then(() => new global.Promise((resolve, reject) => {
                    // setup sauce connect for localhost tunnel
                    const sauceConnectLauncher = require('sauce-connect-launcher');
                    let scTask = app.log('Setting up sauce connect...', true);
                    sauceConnectLauncher({

saucelabs

A wrapper around Sauce Labs REST API

Apache-2.0
Latest version published 3 months ago

Package Health Score

89 / 100
Full package analysis