defunctzombie / zuul

[UNMAINTAINED] multi-framework javascript browser testing
958 stars 86 forks source link

Need to update saucelabs job info after test otherwise saucelabs won't work #288

Open dzcpy opened 8 years ago

dzcpy commented 8 years ago

Currently if we use zuul + saucelabs to test, regardless if all tests pass or not, saucelabs always show an unknown barge.

See this project to prove: https://github.com/algolia/faux-jax

After tried many time, I have found the reason. Here is the reason from saucelabs' documentation:

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 or WebDriver API.

What we need here is to use saucelabs api to update the job with an 'passed' field to indicate whether the test has passed on client site and it must be updated explicitly during a separate API call. And here is how karma-runner module did it:

dzcpy commented 8 years ago

Here is an example code on how to update it on my own:

#!/usr/bin/env node
const Promise = require('bluebird');
const jsome = require('jsome');
const axios = require('axios');
const SauceLabs = require('saucelabs');

const cred = {
  username: process.env.SAUCE_USERNAME,
  password: process.env.SAUCE_ACCESS_KEY
};

const sauce = Promise.promisifyAll(
  new SauceLabs(cred)
);

sauce
  .getJobsAsync()
  .then(result => {
    result = result.map(item => item.id);
    return Promise.map(result, id => {
      return sauce.updateJobAsync(id, {passed:true, name:'transliteration browser test', public: 'public', build: 1, 'tags':[]})
    }, { concurrency: 10 })
    .then(result => {
      jsome(result);
    });
  });