Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

MethodDescriptionURLMethod TypeRequest FieldsExample Request

Start JS Unit Tests

Start your JavaScript unit tests on as many browsers as you like with a single request:username/js-testsPOST
  • platforms (required): an array of desktop platforms
  • url(required): should point to the page that hosts your tests.
  • framework (required): can be "qunit""jasmine""YUI Test""mocha", or "custom".

The custom framework checks window.global_test_results on the test page and uses whatever object supplied there to get test results. Read about it here.

Note
titleSupported Jasmine Version

Only the Jasmine 2 framework is supported.  

 

Expand
titleOS X/Linux Example

curl https://saucelabs.com/rest/v1/YOUR_USERNAME/js-tests \ -X POST \ -u YOUR_USERNAME:YOUR_ACCESS_KEY \ -H 'Content-Type: application/json' \ --data '{  "platforms": [["Windows 7", "firefox", "27"],  ["Linux", "googlechrome", ""]],  "url": "https://saucelabs.com/test_helpers/front_tests/index.html",  "framework": "jasmine"}'

 

Expand
titleWindows Example

curl https://saucelabs.com/rest/v1/YOUR_USERNAME/js-tests -X POST -u YOUR_USERNAME:YOUR_ACCESS_KEY -H 'Content-Type: application/json' -d platforms="[[\"Windows 8\", \"internet explorer\", \"10\"][\"OS X 10.8\", \"safari\", \"6\"]]" -d url="https://saucelabs.com/test_helpers/front_tests/index.html" -d framework=jasmine -d name=sauce-sample-test

Tip
titleUsing Sauce Connect

Hosting your tests on your LAN or your laptop? You'll need to run Sauce Connect to bridge Sauce Labs to your local network. Optional parameters related to Sauce Connect include:

  • tunnelIdentifier: specifies the ID of a specific tunnel when using multiple Sauce Connect tunnels.
  • parentTunnel: specifies the username of a parent account whose shared Sauce Connect tunnel your tests should use.

Any other parameters get passed on as Optional Desired Capabilities for the selenium Selenium server. This means you can set things like: maxDuration

The default maxDuration for all JS unit tests is 180 seconds.

Get JS Unit Test Status

Get the status of your JS unit tests:username/js-tests/statusPOST
    • js tests (required): an array of job ids which you would like the status of

curl https://saucelabs.com/rest/v1/YOUR_USERNAME/js-tests/status \ -X POST \ -u YOUR_USERNAME:YOUR_ACCESS_KEY \ -H 'Content-Type: application/json' \ -d '{"js tests": ["JOB_ID_1","JOB_ID_2"]}'

Make the request multiple times as the tests run until the response contains completed: true to the get the final results.