i read http://webdriver.io/guide/testrunner/cloudservices.html, not find how launch tunnel inside wdio.conf.js , how integrate.
update:
now webdriver.io latest version have documentation integrate cloud testing services.
see more:
http://webdriver.io/guide/testrunner/cloudservices.html
fomerly integrate sauce-connect-launcher need wdio.conf.js file, , inside file configure sauce-connect-launcher launch tunnel, example wdio.conf.js file:
var sauceconnectlauncher = require('sauce-connect-launcher'); global.sauceconnectprocess = null; exports.config = { // // ================== // specify test files // ================== // define test specs should run. pattern relative directory // `wdio` called. notice that, if calling `wdio` // npm script (see https://docs.npmjs.com/cli/run-script) current working // directory package.json resides, `wdio` called there. // user: 'the_pianist2', key: '27dde83a-1cf7-450d-8c88-857c4d3cde43', specs: [ //command line //'spec/**/*.js' wdio wdio.conf.js //grunt './www-test/e2e/spec/*.js' ], // patterns exclude. exclude: [ // 'path/to/excluded/files' ], // // ============ // capabilities // ============ // define capabilities here. webdriverio can run multiple capabilties @ same // time. depending on number of capabilities, webdriverio launches several test // sessions. within capabilities can overwrite spec , exclude option in // order group specific specs specific capability. // // if have trouble getting important capabilities together, check out // sauce labs platform configurator - great tool configure capabilities: // https://docs.saucelabs.com/reference/platforms-configurator // capabilities: [{ browsername: 'chrome' }, { browsername: 'firefox' } ], // // =================== // test configurations // =================== // define options relevant webdriverio instance here // // level of logging verbosity. //loglevel: 'result', // // enables colors log output. coloredlogs: true, // // saves screenshot given path if command fails. screenshotpath: './errorshots/', // // set base url in order shorten url command calls. if url parameter starts // "/", base url gets prepended. //desarrollo baseurl: 'http://localhost:3001', //produccion //baseurl: 'http://www.example.com', // // default timeout waitforxxx commands. waitfortimeout: 20000, // // initialize browser instance webdriverio plugin. object should have // plugin name key , desired plugin options property. make sure have // plugin installed before running tests. following plugins // available: // webdrivercss: https://github.com/webdriverio/webdrivercss // webdriverrtc: https://github.com/webdriverio/webdriverrtc // browserevent: https://github.com/webdriverio/browserevent // plugins: { // webdrivercss: { // screenshotroot: 'my-shots', // failedcomparisonsroot: 'diffs', // mismatchtolerance: 0.05, // screenwidth: [320,480,640,1024] // }, // webdriverrtc: {}, // browserevent: {} // }, // // framework want run specs with. // following supported: mocha, jasmine , cucumber // see also: http://webdriver.io/guide/testrunner/frameworks.html // // make sure have node package specific framework installed before running // tests. if not please install following package: // mocha: `$ npm install mocha` // jasmine: `$ npm install jasmine` // cucumber: `$ npm install cucumber` framework: 'jasmine', // // test reporter stdout. // following supported: dot (default), spec , xunit // see also: http://webdriver.io/guide/testrunner/reporters.html reporter: 'spec', reporteroptions: { // // if using "xunit" reporter should define directory // webdriverio should save unit reports. outputdir: './' }, // // options passed jasmine. jasminenodeopts: { // // jasmine default timeout defaulttimeoutinterval: 20000, // // jasmine framework allows intercept each assertion in order log state of application // or website depending on result. example pretty handy take screenshot everytime // assertion fails. expectationresulthandler: function(passed, assertion) { } }, // // ===== // hooks // ===== // run functions before or after test. if 1 of them returns promise, webdriverio // wait until promise got resolved continue. // // gets executed before workers launched. onprepare: function() { return new promise(function(resolve, reject) { sauceconnectlauncher({ username: 'the_pianist2', accesskey: '27dde83a-1cf7-450d-8c88-857c4d3cde43', }, function (err, sauceconnectprocess) { if (err) { return reject(err); } console.log('conexion realizada'); global.sauceconnectprocess = sauceconnectprocess resolve(); }); }); }, // // gets executed before test execution begins. @ point have access global // variables `browser`. perfect place define custom commands. before: function() { // }, // // gets executed after tests done. still have access global variables // test. after: function(failures, pid) { // }, // // gets executed after workers got shut down , process exit. not // possible defer end of process using promise. oncomplete: function() { console.log('test completado'); global.sauceconnectprocess.close(function () { console.log("closed sauce connect process"); return true; }); }};
in hook 'onprepare' script connect tunnel launch , inside promise important because wait callback of connection , run next steps after finish onprepare functions:
https://github.com/webdriverio/webdriverio/issues/1062
after test launching on server saucelabs.
Comments
Post a Comment