Skip to end of metadata
Go to start of metadata

Status badges and the Sauce Labs browser matrix widget help you keep track of the status of your latest test runs. All you have to do is add either markdown or HTML code to your GitHub README or project site that references your Sauce Labs username and access key, and annotate your tests with the REST API

Status Badges and the Browser Matrix

There are four status badges that correspond to the three states of a finished test: Passing, Failed, Error, and Unknown.

BadgeStatus
Passing
Failing
This status is set if the build errors out due to an internal error (one or more sessions have crashed)
This status is set if one or more jobs of the latest build haven't been reported as passed or failed. This state is equivalent to Finished.

With the browser matrix, you can keep track of the test status of your project for various browser/platform/operating system combinations.


Build Status Badge Example

Build Status


Browser Matrix Badge Example

Browser Matrix


Setting Up Status Badges for Test Results

  1. Copy this markdown code into your GitHub README.

    [![Sauce Test Status](https://saucelabs.com/buildstatus/YOUR_SAUCE_USERNAME)](https://app.saucelabs.com/u/YOUR_SAUCE_USERNAME)

    Alternatively, you can use this HTML code on your project site.

    <a href="https://app.saucelabs.com/u/YOUR_SAUCE_USERNAME">
      <img src="https://saucelabs.com/buildstatus/YOUR_SAUCE_USERNAME" alt="Sauce Test Status"/>
    </a> 

    Multiple Projects, Multiple Accounts

    If you just have one project, you can use your main Sauce account name. If you have multiple projects, you will want to create a sub-account for each project. 

  2. Run your tests.

  3. Make sure to set a build number, a pass/fail status, and a public, share, or public restricted visibility for every test that runs using the Test Configuration Options.
    You'll know that these are set correctly if your tests have a status of Pass or Failed instead of Finished on your dashboard, and that a build number is also displayed.

Setting Up the Browser Matrix Widget

Copy this markdown code into your project's GitHub README.

[![Sauce Test Status](https://saucelabs.com/browser-matrix/YOUR_SAUCE_USERNAME.svg)](https://saucelabs.com/u/YOUR_SAUCE_USERNAME)

Alternatively, you can add this HTML to your project site.

<a href="https://saucelabs.com/u/YOUR_SAUCE_USERNAME">
  <img src="https://saucelabs.com/browser-matrix/YOUR_SAUCE_USERNAME.svg" alt="Sauce Test Status"/>
</a> 


Note that the above information applies to Open Sauce accounts only. Open Sauce accounts are public, meaning tests and build status can be viewed without authentication. In order to use the above for any other type of account, read on.

Status Images for Private Accounts

If you want to display the build status of a private Sauce account, you need to provide a Hash-based Message Authentication Code (HMAC) token generated from your username and access key.

This example shows how to generate an HMAC token using Python:

python
from hashlib import md5
import hmac
"?auth=" + hmac.new("YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESSKEY", None, md5).hexdigest()

This is an example to show that the HMAC token should be generated using your Sauce Labs username and access key. You can find many examples of how to accomplish this in other languages with a quick web search, such as here. As the above example shows, the HMAC token should be generated using the md5 cryptographic algorithm, and with no secret.

Once you have the token, append it to the badge URL:

https://saucelabs.com/buildstatus/YOUR_SAUCE_USERNAME?auth=HMAC_TOKEN


Example Demo

Follow the instructions below to run the sample demo that exists in the saucelabs-training GitHub organization:

How to Run This Demo:

  1. Clone this repository:

    git clone https://github.com/saucelabs-training/demo-sauce-status-badge.git
    
  2. Set your Sauce Labs Credentials as environment variables

  3. Add the username for the badge and matrix URLs like so:

    • Build Status Badge Example URL:
      [![Build Status](https://saucelabs.com/buildstatus/SAUCE_USERNAME)](https://app.saucelabs.com/u/SAUCE_USERNAME)
      
      
    • Browser Matrix Example URL:
      [![Browser Matrix](https://saucelabs.com/browser-matrix/SAUCE_USERNAME.svg)](https://saucelabs.com/u/SAUCE_USERNAME)
      
  4. Navigate to the project directory and run:

    npm install
    
  5. Run the tests with the following command:

    npm test
    



10 Comments

  1. Anonymous

    What is the refresh time of badges and matrixes? I've just run a build, and in the browser matrix (https://saucelabs.com/u/YOUR_SAUCE_USERNAME) only a few of the tested browsers appear; while in the badge page (https://saucelabs.com/u/YOUR_SAUCE_USERNAME) shows them all.

     

    Nonetheless, all items in the badgepage appear in gray, while they should be green. Note that the results in the table are marked as "Pass".

    1. Anonymous

      Same behaviour here. All tests are either passed or failed, and still both badge and browser matrix shows UNKOWN.

    2. Anonymous

      Same issue here

  2. Anonymous

    Same here ...

  3. Anonymous

    Yup same here. Cannot get it working.

  4. Anonymous

    [![Sauce Test Status](https://saucelabs.com/browser-matrix/YOUR_SAUCE_USERNAME.svg)](https://saucelabs.com/u/YOUR_SAUCE_USERNAME)
  5. Anonymous

    still showing unknown

     

  6. Hi, we've identified the bug causing this and will deploy a fix within the next two weeks. I'll reply here when it goes out. 

  7. Anonymous

    Hello, has the fix been deployed? i still see the bug

  8. Anonymous