UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

137 lines (107 loc) 4.65 kB
/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ Class('Siesta.Launcher.Runner.WebDriverNodeJS.LambdaTest', { isa : Siesta.Launcher.Runner.WebDriverNodeJS, does : [ Siesta.Launcher.Runner.WebDriverNodeJS.WithTunnel ], has : { // increased page poll interval to reduce trafic pagePollInterval : 5000, tunnelName : 'LambdaTest' }, methods : { onWebDriverInstatiationException : function (e) { // var str = String(e) // // if (str.indexOf('sessions are currently being used. Please upgrade to add more parallel sessions') != -1) { // this.warn("Max number of parallel sessions exceeded, reducing --max-workers config by 1") // // this.maxWorkers = Math.max(1, this.maxWorkers - 1) // // return false // } // // if (str.indexOf('Browser/Browser_Version not supported') != -1) { // this.printError("This combination of browser and browser version is not supported") // // return false // } // // if (str.indexOf('OS/Browser combination invalid') != -1) { // this.printError("This combination of OS and browser is not supported") // // return false // } // // var match // // if (match = /Platform can be one of (.*)/.exec(str)) { // this.printError("The `--cap platform=value` should be one of " + match[ 1 ]) // // return false // } return this.SUPER(e) }, buildCapabilities : function () { var caps = this.SUPERARG(arguments) var options = this.dispatcher.options caps.set('visual', options[ 'lambdatest-enable-screenshots' ] ? 'true' : 'false') var tunnelId = this.tunnelId || options[ 'lambdatest-tunnel-identifier' ] if (tunnelId) { caps.set('tunnelName', tunnelId) } return caps }, // promised method setup : function () { var me = this return this.SUPER().then(function () { var launcher = me.launcher var options = launcher.options var lt = options.lt if (!lt) throw new Error("This runner should only be used when LambdaTest is enabled") if (!lt.shortCut || lt.noTunnel) return me me.initTunnelId() var args = [] args.push('--user', lt.userName) args.push('--key', lt.key) args.push('--tunnelName', me.tunnelId) args.push('--mitm') lt.ltTunneledDomains && args.push('--allowHosts', lt.ltTunneledDomains) if (options.coverage) { args.push('--proxy-host', '127.0.0.1') args.push('--proxy-port', me.dispatcher.instrumentationProxyPort) // lambda test fetches the default tunnel config from the `ts.lambdatest.com` // and if this request goes through the proxy, it fails because of the proxie's self-signed certificate args.push('--no-proxy', 'ts.lambdatest.com') } if (options[ 'proxy-host' ]) { args.push('--proxy-host', options[ 'proxy-host' ]) if (options[ 'proxy-port' ]) { args.push('--proxy-port', options[ 'proxy-port' ]) } if (options[ 'proxy-user' ]) { args.push('--proxy-user', options[ 'proxy-user' ]) } if (options[ 'proxy-password' ]) { args.push('--proxy-pass', options[ 'proxy-password' ]) } } me.tunnelInfo = lt.userName return me.launchTunnel( launcher.binDir + '/binary/lambdatest/' + launcher.getPlatformId() + '/LT' + (launcher.isWindows ? '.exe' : ''), args, undefined, function (line) { return /You can start testing now/.test(line) } ) }) } } })