GitXplorerGitXplorer
J

JSUnitSaucelabs

public
4 stars
1 forks
2 issues

Commits

List of commits on branch master.
Verified
4edf4fa8be5750754c9e54919a95ab0063dccab5

fix typo in package.json

JJohann-S committed 7 years ago
Unverified
61d1ac7ddf447bac8d886274b40bc73858a7a688

1.3.2

JJohann-S committed 7 years ago
Unverified
fe80bea99e541e47244893b4b2396a55cdb71b73

Add README.md and LICENSE to distributed files

JJohann-S committed 7 years ago
Unverified
55465c729cf79a3d90e86c8f14b771cfab0fc317

1.3.1

JJohann-S committed 7 years ago
Unverified
ae91e60dde4c414fa16b0adb6a5634d27b82d7d0

update timeout for index unit test

JJohann-S committed 7 years ago
Unverified
92eb33f8119c99f145a536596bab9c946bac9806

add some tests for util

JJohann-S committed 7 years ago

README

The README file for this repository.

JSUnitSaucelabs

npm version dependencies Status devDependencies Status Build Status

Allows you to run your unit tests through Sauce Labs API without Grunt.

Used by

If you want to add your project here do not hesitate to open a PR 😉

Install

npm install jsunitsaucelabs --save-dev

Methods

Constructor

JSUnitSaucelabs constructor accepts the following parameters (the following are the default values):

{
  username:    null,
  password:    null,
  tunneled:    true,
  build:       null,
  verbose:     false,
  verboseMode: null, // accept : "debug", "info", "warn"
  hostname:    'saucelabs.com',
  base:        '/rest/v1/'
}

JSUnitSaucelabs.prototype.initTunnel

This method allows you to initialise a tunnel between you and Sauce Labs, when this tunnel is started, JSUnitSaucelabs will emit tunnelCreated event

JSUnitSaucelabs inherit from EventEmitter

JSUnitSaucelabs.prototype.start

This method uses :username/js-tests from Sauce Labs API. See here.

Parameters

  • platforms: Array of platforms
  • url: should point to the page that hosts your tests
  • framework: the framework used for your tests (QUnit, Jasmine, ...)
  • callback: function to handle error or success callback(error, result)

If you use a tunnel between Sauce Labs and you, you shouldn't call start before the connection is established (see initTunnel method)

JSUnitSaucelabs.prototype.getStatus

This method uses :username/js-tests/status from Sauce Labs API. See here.

Parameters

  • taskIds: Array of task IDs returned by Sauce Labs API
  • callback: function to handle error or success callback(error, result)

JSUnitSaucelabs.prototype.stop

Allows you to stop the tunnel between you and Sauce Labs

Usage Example

var JSUnitSaucelabs = require('jsunitsaucelabs')

var jsUnitSaucelabs = new JSUnitSaucelabs({
  username: 'your-saucelabs-username',
  password: 'your-saucelabs-api-key'
})

var testURL = 'http://localhost/index.html?hidepassed'

jsUnitSaucelabs.on('tunnelCreated', function () {
  jsUnitSaucelabs.start([
    ['Windows 8', 'internet explorer', '10']/*,
    ['OS X 10.8', 'safari', '6']*/
  ], testURL, 'qunit', function (error, success) {
    if (typeof success !== undefined) {
      var taskIds = success['js tests']
      if (!taskIds || !taskIds.length) {
        throw new Error('Error starting tests through Sauce Labs API')
      }

      var waitingCallback = function (error, success) {
        if (error) {
          console.error(error)
          return
        }

        if (typeof success !== 'undefined') {
          if (!success.completed) {
            jsUnitSaucelabs.getStatus(taskIds[0], waitingCallback)
          } else {
            var test = success['js tests'][0]
            var passed = false
            if (test.result !== null) {
              passed = test.result.total === test.result.passed
            }
            console.log('Tested ' + testURL)
            console.log('Platform: ' + test.platform.join(','))
            console.log('Passed: ' + passed.toString())
            console.log('Url ' + test.url)
          }
        }
      }

      taskIds.forEach(function (id) {
        jsUnitSaucelabs.getStatus(id, waitingCallback)
      })
    }
  })
})

jsUnitSaucelabs.initTunnel()

License

MIT