Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsunitsaucelabs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsunitsaucelabs

Allows you to run your unit test through Sauce Labs without Grunt

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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 :wink:

  • Bootstrap

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

Keywords

FAQs

Package last updated on 19 Apr 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc