Skip to content

Commit

Permalink
Chore: update status for jobs in saucelabs (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanDeMicco authored Mar 12, 2018
1 parent 7da455b commit d133dc0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
7 changes: 5 additions & 2 deletions codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const commonConfigObj = {
};

const helperObj = {};
if (typeof SAUCE_USERNAME === 'undefined') {
const isLocalBuild = typeof SAUCE_USERNAME === 'undefined';

if (isLocalBuild) {
helperObj.WebDriverIO = commonConfigObj;
} else {
// Common saucelab config
Expand Down Expand Up @@ -69,5 +71,6 @@ exports.config = {
include: {},
bootstrap: false,
mocha: {},
name: 'box-content-preview'
name: 'box-content-preview',
hooks: isLocalBuild ? [] : ['./functional-tests/eventHooks.js']
};
33 changes: 33 additions & 0 deletions functional-tests/eventHooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { event, container } = require('codeceptjs');
const SauceLabs = require('saucelabs');

const { SAUCE_USERNAME, SAUCE_ACCESS_KEY } = process.env;

module.exports = function() {
const myAccount = new SauceLabs({
username: SAUCE_USERNAME,
password: SAUCE_ACCESS_KEY
});
/**
* Reports to saucelabs if a job has passed or failed
* @param {Object} test - the test object from codeceptjs
* @param {boolean} isPassed - true if passed
* @return {void}
*/
const updateStatus = (test, isPassed) => {
const sessionId = container.helpers('WebDriverIO').browser.requestHandler.sessionID;

myAccount.updateJob(sessionId, {
name: test.title,
passed: isPassed
});
};

event.dispatcher.on(event.test.passed, (test) => {
updateStatus(test, true);
});

event.dispatcher.on(event.test.failed, (test) => {
updateStatus(test, false);
});
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"react-dom": "^16.2.0",
"react-virtualized": "^9.13.0",
"sass-loader": "^6.0.6",
"saucelabs": "^1.4.0",
"selenium-webdriver": "^3.6.0",
"sinon": "^4.1.2",
"sinon-chai": "2.14.0",
Expand Down
39 changes: 32 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ [email protected]:
version "0.8.2"
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"

agent-base@2:
version "2.1.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7"
dependencies:
extend "~3.0.0"
semver "~5.0.1"

ajv-keywords@^2.0.0, ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
Expand Down Expand Up @@ -2366,6 +2373,12 @@ dateformat@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.2.tgz#9a4df4bff158ac2f34bc637abdb15471607e1659"

debug@2, [email protected], debug@^2.2.0, debug@^2.6.8:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"

[email protected]:
version "2.2.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da"
Expand All @@ -2378,12 +2391,6 @@ [email protected]:
dependencies:
ms "0.7.2"

[email protected], debug@^2.2.0, debug@^2.6.8:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"

[email protected], debug@^3.0.0, debug@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
Expand Down Expand Up @@ -3202,7 +3209,7 @@ express@^4.15.2:
utils-merge "1.0.1"
vary "~1.1.2"

extend@^3.0.0, extend@~3.0.0, extend@~3.0.1:
extend@3, extend@^3.0.0, extend@~3.0.0, extend@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"

Expand Down Expand Up @@ -4050,6 +4057,14 @@ [email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"

https-proxy-agent@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6"
dependencies:
agent-base "2"
debug "2"
extend "3"

husky@^0.14.3:
version "0.14.3"
resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3"
Expand Down Expand Up @@ -7226,6 +7241,12 @@ sass-loader@^6.0.6:
lodash.tail "^4.1.1"
pify "^3.0.0"

saucelabs@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-1.4.0.tgz#b934a9af9da2874b3f40aae1fcde50a4466f5f38"
dependencies:
https-proxy-agent "^1.0.0"

sax@>=0.6.0, sax@~1.2.1:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
Expand Down Expand Up @@ -7264,6 +7285,10 @@ semver@~4.3.3:
version "4.3.6"
resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da"

semver@~5.0.1:
version "5.0.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a"

semver@~5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
Expand Down

0 comments on commit d133dc0

Please sign in to comment.