sauce-test-runner

0.2.0 • Public • Published

sauce-test-runner

Build Status

Node module for running tests using SauceLabs automated tests feature to run on several different browsers

Install

npm install --save-dev sauce-test-runner

Usages

Simple Usage with gulp

const saucelabs = require('gulp-saucelabs');
const connect   = require('gulp-connect');
 
// Saucelabs 
gulp.task('saucelabs', () => {
    const config = {
      urls: ['http://localhost:3000/tests/qunit/index.html'],
      testname: 'My test',
      framework: 'qunit',
      browsers: [
          {
              browserName: "MicrosoftEdge",
              platform: "Windows 10",
              version: "latest"
          }
      ],
      onTestSuiteComplete: (status) => {
          if (status) {
              console.log('All tests passed!');
          }
      };
    }
 
    return saucelabs(config);
});
 
// Start local http server 
gulp.task('connect', () => {
    connect.server({ port: 3000, root: './' });
});
 
// Close down the http server 
gulp.task('disconnect', () => {
    connect.serverClose();
});
 
gulp.task('test-saucelabs', ['connect', 'saucelabs'], () => gulp.start('disconnect'));

Options

Example:

const config = {
    username: 'foo-bar',
    key: 'xxxx-xxxx-xxxx-xxxx-xxxx',
    urls: ['http://localhost:3000/tests/index.html'],
    testname: 'My test',
    framework: 'qunit',
    logger: {
        log: console.log,
        debug: console.log,
    },
    debug: false,
    browsers: [
        {
            browserName: "MicrosoftEdge",
            platform: "Windows 10",
            version: "latest"
        },
        {
            browserName: "internet explorer",
            version: "11",
            platform: "Windows 8.1"
        },
        {
            browserName: "internet explorer",
            version: "10",
            platform: "Windows 8"
        }
    ],
    onTestSuiteComplete: (status) => {
        if (status) {
            console.log('All tests passed!');
        }
    }
    ...
}

username

Username to SauceLabs. If not provided, uses the value of SAUCE_USERNAME environment variable. Optional

key

Accesskey for SauceLabs. If not provided, uses the value of SAUCE_ACCESS_KEY environment variable. Optional

build

The build number for this test. Optional

urls

An array or URLs that will be loaded in the browsers, one after another. Required

framework

Which framework to test. Options: qunit, jasmine, mocha, custom. Required

testname

name of the test, displayed on the SauceLabs dashboard. Optional

tags

An array of strings, to be added as tags to the test on Sauce Labs. Optional

tunneled

Defaults to true; Won't launch a Sauce Connect tunnel if set to false. Optional

tunnelArgs

Array of optional arguments to be passed to the Sauce Connect tunnel. example: ['--debug', '--direct-domains', 'google.com']. See here for further documentation.

sauceConfig

Map of extra parameters to be passed to sauce labs. example: {'video-upload-on-pass': false, 'idle-timeout': 60}. See here for further documentation.

pollInterval

Number of milliseconds between each retry to see if a test is completed or not (default: 2000). Optional

statusCheckAttempts

Number of times to attempt to see if a test is completed or not (default: 90). Effectively, your tests have statusCheckAttempts * pollInterval seconds to complete (Thus, 180s by default). Set to -1 to try forever. Optional

throttled

Maximum number of unit test pages which will be sent to Sauce Labs concurrently. Exceeding your SauceLabs' allowed concurrency can lead to test failures if you have a lot of unit test pages. Optional

maxDuration

Maximum duration of a test, this is actually a Selenium Capability. SauceLabs defaults to 180 seconds for js unit tests. Optional

browsers

An array of objects representing the various browsers on which this test should run. Optional

onTestComplete

A callback that is called every time a unit test for a page is complete. Runs per page, per browser configuration. Receives two arguments (result, callback). result is the javascript object exposed to SauceLabs as the results of the test. callback must be called, node-style (having arguments err, result where result is a true/false boolean which sets the test result reported to the command line). Optional

onException

A callback that is called when the tunnel does not close properly and we had to cancel the promise waiting for the tunnel to close.

onTestSuiteComplete

A callback that is called when all tests have run and the tunnel has been closed down. The callback receives one argument (boolean) which is true if all tests passed, otherwise false.

logger

Logger functions, used to print the test output. The logger object needs to define two methods: log and debug which take a sequence of strings as arguments. Defaults to console.log.

debug

Specifies if the module should invoke logger.debug to print saucelabs tunnel info messages.

maxRetries

Specifies how many times the timed out tests should be retried (default: 0). Optional

public

The job visibility level. Defaults to 'team'. Optional

Contribution

Forked from https://github.com/axemclion/grunt-saucelabs

Changelog

0.1.4

Added callback and timeout for when the tunnel does not stop

0.1.3

Removed YUI support

Package Sidebar

Install

npm i sauce-test-runner

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • bytbil