diff --git a/codecept.conf.js b/codecept.conf.js index 4a0477508..d4ba41520 100644 --- a/codecept.conf.js +++ b/codecept.conf.js @@ -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 @@ -69,5 +71,6 @@ exports.config = { include: {}, bootstrap: false, mocha: {}, - name: 'box-content-preview' + name: 'box-content-preview', + hooks: isLocalBuild ? [] : ['./functional-tests/eventHooks.js'] }; diff --git a/functional-tests/eventHooks.js b/functional-tests/eventHooks.js new file mode 100644 index 000000000..45a90c909 --- /dev/null +++ b/functional-tests/eventHooks.js @@ -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); + }); +}; diff --git a/package.json b/package.json index 2fbcd1a93..15682758a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index c0de6dbcf..d84590d59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -175,6 +175,13 @@ after@0.8.2: 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" @@ -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, debug@2.6.9, 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" + debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -2378,12 +2391,6 @@ debug@2.3.3: dependencies: ms "0.7.2" -debug@2.6.9, 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" - debug@3.1.0, debug@^3.0.0, debug@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" @@ -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" @@ -4050,6 +4057,14 @@ https-browserify@0.0.1: 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" @@ -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" @@ -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"