@testim/testim-cli 4.183.7 → 4.184.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/cli.js +1 -1
- package/cli.js.map +2 -2
- package/npm-shrinkwrap.json +637 -569
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# TESTIM.IO
|
|
3
3
|
## Web & Mobile Test Automation Solution. Built for agile teams. Testim is a cloud service that instantly enables Test Automation to make your Continuous Delivery ready.
|
|
4
4
|
|
|
5
|
-
For more information please check out https://testim.io and https://
|
|
5
|
+
For more information please check out https://testim.io and https://docs.tricentis.com/testim/content/overview/testim-overview/index.htm
|
|
6
6
|
|
|
7
7
|
For any questions please talk to our support from the chat window at https://app.testim.io
|
|
8
8
|
|
|
9
|
-
For the live and up to date documentation of this tool please check out [this guide](https://
|
|
9
|
+
For the live and up to date documentation of this tool please check out [this guide](https://docs.tricentis.com/testim/content/integrations/integrate-testim-to-your-ci/index.htm) on integrating Testim into your CI/CD.
|
|
10
10
|
|
|
11
11
|
### Installation
|
|
12
12
|
|
package/cli.js
CHANGED
|
@@ -413,7 +413,7 @@ Turbo mode is not allowed for your current plan, please upgrade your plan at htt
|
|
|
413
413
|
\x1B[4m\x1B[36mOur Free grid offers basic service performance.
|
|
414
414
|
If you need faster results, contact us to upgrade your plan and dramatically improve your tests\u2019 run times.\x1B[0m
|
|
415
415
|
`)}function ZR(s,e,t){s==="redis"&&Dn.start(t,e),s==="mongo"&&Cn.start(e)}async function ex(s,e,t){s==="redis"&&await Dn.end(t,e),s==="mongo"&&await Cn.end(e)}async function tx(s){var h,g,y,w,S,b;M("start runner init");let{project:e,lightweightMode:t,useChromeLauncher:r,mode:n,disableSockets:i}=s,o=FR(e,{disableResults:i||Boolean((t==null?void 0:t.disableResults)&&(r||n===J.SELENIUM)),disableRemoteStep:i||Boolean(t==null?void 0:t.disableRemoteStep)});o.catch(()=>{});let{authData:a,companyByProjectId:c,projectById:l,branchName:d,allGrids:m,clientConfig:u}=await yi(s);if(c.disabled)throw new x("The company is disabled.");if(l.disabled)throw new x("The project is disabled.");if(s.printGrids){let v=m.sort((T,C)=>T.type.localeCompare(C.type));console.table(v.reduce((T,C)=>{class _{constructor(E,k){this.Type=E,this.Browsers=k}}let B=Object.entries(C.browsers||{"N/A":""}).map(G=>G.join(":")).join(", ");return T[C.name]=new _(C.type,B),T},{})),process.exit(0)}if(await o,M("after featureFlagsReady and socketConnected"),WR(s,u.editorUrl),$R(s,c),HR(s,l),zR(s,l),UR(s,d),VR(s,m),GR(s,a),await jR(s),await BR(s,l),await qR(s),await JR(s),DR(s,c),(h=s.extensionLocation)!=null&&h.length||(s.extensionLocation=[Wg(s)]),O.flags.clearRunnerFileCache.isEnabled())try{await ls(),kd.info("runner file cache cleared")}catch(v){kd.error("failed to clear runner file cache",{err:v})}(g=s.lightweightMode)!=null&&g.disableLabs||await Jn.loadLabFeatures(l.id,c.activePlan),((y=s.lightweightMode)==null?void 0:y.type)==="turboMode"&&(O.flags.highSpeedMode.getValue()==="disabled"||s.company.planType==="free")&&delete s.lightweightMode,((w=s.lightweightMode)==null?void 0:w.type)==="turboMode"&&console.log(`
|
|
416
|
-
Turbo mode will ignore step delays. Test artifacts like screenshots and logs will only be saved for failed runs. For more information see our docs: https://
|
|
416
|
+
Turbo mode will ignore step delays. Test artifacts like screenshots and logs will only be saved for failed runs. For more information see our docs: https://docs.tricentis.com/testim/content/testops/turbo-mode.htm`),ZR(s.slotService,e,c.id),MR(e),await KR(s),QR(s);let f=Pn();await Z.setOptions(s,f),(b=(S=s.testOptimization)==null?void 0:S.seaLights)!=null&&b.testStage&&s.testOptimization.seaLights.testStage!==OR&&gs(a.uid,"cli-sealights_stage_changed",{testStage:s.testOptimization.seaLights.testStage,projectId:e})}var QT,XT,YT,OR,kd,LR,YR,ew=I(()=>{"use strict";QT=R(require("lodash"));F();Pd();Ve();fs();Ts();kr();Fl();ye();mt();Jt();W();Bt();le();ae();Q();jp();Jo();Ou();me();_n();id();Vn();XT=30*60*1e3,YT=1,OR="Testim Automation",kd=A("runner");LR={desktopWeb:"web",mobileWeb:"web",android:"mobile",ios:"mobile",sfdc:"sfdc"};YR=XR});function tw(s){s.get("/",(e,t)=>{let r=Od();return t.status(200).json({success:!0,isTestimAgent:!0,startMode:r})}),s.get("/version",(e,t)=>{t.status(200).json({node:process.version,app:sc()})}),s.get("/loginInfo",(e,t)=>{try{let r=JSON.parse(Buffer.from(e.query.info,"base64").toString());md({overwriteExisting:!1,projects:r}),t.status(200).end()}catch{t.status(400).end()}})}var rw=I(()=>{"use strict";ac();_d();rd()});var Ld,sw,yr,gc,nw=I(()=>{"use strict";Ld=R(require("chalk"));Os();sw=require("express");W();Q();ol();yr=A("cli-router"),gc=(0,sw.Router)();gc.post("/run",async(s,e)=>{let{code:t,stepId:r,incomingParams:n,context:i,testResultId:o,retryIndex:a,stepResultId:c,timeout:l,fileDataUrl:d}=s.body;if(typeof t!="string"||!r||!n||!i||!o||typeof a!="number"||!c||typeof l!="number"){e.status(400).json({success:!1,code:"invalid-params"});return}if(n.nodePackageParams){let u=n.nodePackageParams.map(h=>h.testimPackageLocalLocation).filter(Boolean),f=il(u);if(f){yr.error("Invalid package paths detected",{invalidPaths:f,stepId:r,testResultId:o}),e.status(400).json({success:!1,code:"invalid-package-path",message:`Invalid package path(s) detected: ${f.join(", ")}`});return}}let m={stepId:r,testResultId:o,retryIndex:a,stepResultId:c,timeout:l,fileDataUrl:d,nodePackageParams:n.nodePackageParams};try{let u=await ks(t,r,n,i,o,a,c,l,d);u.success||(console.log(Ld.default.red(u.result.resultValue)),yr.error("CLI Action Failure",{message:u.result.resultValue,...m})),e.status(200).json({success:!0,data:u})}catch(u){yr.error("failed to run cli code",{err:u,...m}),console.log(Ld.default.red("failed to run cli code",u)),e.status(500).json({success:!1,code:"internal-error"})}});gc.post("/install",async(s,e)=>{let{stepId:t,testResultId:r,retryIndex:n,packageData:i,stepResultId:o,timeout:a}=s.body;if(!t||typeof i!="object"||!r||typeof n!="number"||!o||typeof a!="number"){e.status(400).json({success:!1,code:"invalid-params"});return}let c=nl(i);if(c){yr.error("Invalid package names detected",{invalidNames:c,stepId:t,testResultId:r}),e.status(400).json({success:!1,code:"invalid-package-name",message:`Invalid package name(s): ${c.join(", ")}`});return}let l={stepId:t,testResultId:r,retryIndex:n,stepResultId:o,timeout:a,packageData:i};try{let d=await Ps(t,r,n,i,o,a);yr.info("installed packages successfully",l),e.status(200).json({success:!0,data:d})}catch(d){if(d instanceof Nt){yr.error("failed to install node packages",{err:d,...l}),e.status(200).json({success:!1,code:"invalid-node-package",message:d.message});return}if(d instanceof ue){yr.error("timeout installing node package",{err:d,...l}),e.status(200).json({success:!1,code:"timeout"});return}yr.error("failed to install node packages",{err:d,...l}),e.status(500).json({success:!1,code:"internal-error"})}})});var iw=I(()=>{"use strict";nw()});var lw={};z(lw,{orchestrateRoutes:()=>rx});function rx(s){let e=(0,aw.default)();e.disable("x-powered-by"),s(e),e.use(Dd.default.urlencoded({extended:!1,limit:"50mb"})),e.use((0,cw.default)()),e.use(Dd.default.json({limit:"50mb"}));let r={methods:["GET","PUT","POST","DELETE","OPTIONS"],allowedHeaders:["Content-Type","Authorization"],credentials:!0,maxAge:86400,origin:Ge||Hd?"*":["chrome-extension://pebeiooilphfmbohdbhbomomkkoghoia"]};return e.use("*",(0,ow.default)(r)),tw(e),e.use("/cliJs",gc),e.use((n,i)=>{i.status(404).send("Endpoint Not Found")}),e}var ow,aw,Dd,cw,uw=I(()=>{"use strict";ow=R(require("cors")),aw=R(require("express")),Dd=R(require("body-parser")),cw=R(require("compression"));rw();iw();le()});var dw={};z(dw,{init:()=>sx});async function sx({agentPort:s,agentBind:e,project:t,token:r}){let{orchestrateRoutes:n}=await Promise.resolve().then(()=>(uw(),lw));return new Promise((i,o)=>{let a=()=>{};t&&(Df(t,r),a=u=>{u.use((f,h,g)=>{Object.assign(f,{project:t}),g()})});let c=n(a),l=pw.createServer(c);l.listen(s,e),l.on("error",d),l.on("listening",m);function d(u){if(u.syscall!=="listen")return o(u);switch(u.code){case"EACCES":case"EPERM":return o(new x(`Port ${s} requires elevated privileges`));case"EADDRINUSE":return o(new x(`Port ${s} is already in use, is another Testim instance running?`));default:return o(u)}}function m(){let{port:u}=l.address();console.log(`Running on port: ${u}`),nx()}})}async function nx(){await require("prompts")({name:"",type:"text",message:'Type the word "stop" or Press Ctrl + C.',validate:t=>t.toUpperCase().trim()==="STOP"}),console.log("Exiting Testim CLI"),process.exit(0)}var pw,mw=I(()=>{"use strict";pw=R(require("http"));mt();Q()});var ww={};z(ww,{getStartedWithStart:()=>Od,runAgentMode:()=>cx});async function cx(s){var r;let e;if(await Cr(s.playerLocation,s.canary),s.startTestimBrowser){await px();try{e=await ux(s)}catch(n){throw(r=n==null?void 0:n.message)!=null&&r.includes("user data directory is already in use")?new x('Please close all chrome browsers that were opened with "testim start" and try again'):n}}let t=await Promise.resolve().then(()=>(mw(),dw));return e!=null&&e.webdriverApi&&setTimeout(()=>{setTimeout(()=>(fp(),Je(Pb)))},6e3),t.init(s)}function Od(){return bw}function fw(s){try{return process.kill(s,0)}catch{return!1}}async function lx(s,e,t){let r=br.join(St,`chrome-${vn}-process`),n=3e3,i=()=>{Le.rmSync(r,{recursive:!0}),console.log(`
|
|
417
417
|
|
|
418
418
|
Browser session ended`),process.exit(0)};if(await Te(r)){let f=JSON.parse(Le.readFileSync(r));if(fw(f.pid)){let h=()=>fw(f.pid)?setTimeout(h,n):i();return h(),{webdriverApi:f}}}let o=await co();await Te(qs)||await Le.promises.mkdir(qs,{recursive:!0});let c=[...Tw(qs,e,t,o).desiredCapabilities.chromeOptions.args,...yc.Launcher.defaultFlags().filter(f=>!["--disable-extensions","--disable-component-extensions-with-background-pages"].includes(f))],l={GOOGLE_API_KEY:"AIzaSyCkfPOPZXDKNn8hhgu3JrA62wIgC93d44k",GOOGLE_DEFAULT_CLIENT_ID:"811574891467.apps.googleusercontent.com",GOOGLE_DEFAULT_CLIENT_SECRET:"kdloedMFGdGla2P1zacGjAQh"},d=s.extensionPath?"http://localhost:3000/app/":new URL("?startMode=true",ot||vr).href,m=await yc.launch({chromeFlags:c,startingUrl:d,ignoreDefaultFlags:!0,userDataDir:qs,chromePath:o,envVars:l}),u={port:m.port,pid:m.pid,cdpUrl:await xr(`localhost:${m.port}`)};return Le.writeFileSync(r,JSON.stringify(u)),m.process.once("exit",i),m.process.once("close",i),{webdriverApi:u}}async function ux(s){let e=`${tr}/testim-full-master.zip`,t=br.basename(e),r=br.join(St,t),n=br.join(St,`${t}__unzipped__`),i=!(s.ext||s.extensionPath);if(i&&await Te(r)){let f=await Le.promises.stat(r);i=Date.now()-ox>f.mtimeMs}if(await Le.promises.mkdir(St,{recursive:!0}),i){let f=(0,hw.default)("Downloading Testim Editor").start();await Qe(e,r);try{await Ze(r,n)}catch{await Le.promises.rm(r,{recursive:!0,force:!0}),await Qe(e,r);try{await Ze(r,n)}catch{throw await Le.promises.rm(r,{recursive:!0,force:!0}),f.fail("Failed to download Testim Editor"),new Error("Failed to download Testim Editor")}}finally{s.downloadBrowser||await Le.promises.rm(n,{recursive:!0,force:!0})}f.succeed()}let o=s.extensionPath?null:(await Le.promises.readFile(s.ext||r)).toString("base64");if(s.downloadBrowser)return await lx(s,o,n);await yn({projectId:s.project},{chromeBinaryLocation:s.chromeBinaryLocations});let a=Tw(qs,o,s.extensionPath,s.chromeBinaryLocations),{WebDriver:c}=(Kn(),Je(Ih)),{SeleniumPerfStats:l}=(Es(),Je(Ng)),d=new c;d.seleniumPerfStats=new l;let m=await d.initClient(a);bw=!0;let u=`${s.extensionPath?"http://localhost:3000/app/":ot||vr}?startMode=true`;await d.url(u),Object.assign(d,{initialUrl:u});try{d.cdpUrl=await xr(m.value["goog:chromeOptions"].debuggerAddress)}catch{}return{webdriverApi:d}}function Tw(s,e,t,r){let n=e?[e]:[],i=[`--user-data-dir=${s}`,"--log-level=OFF","--silent-debugger-extension-api","--no-first-run"];t&&i.push(`--load-extension=${t}`);try{let o=Wo();o.length&&o.forEach(a=>i.push(`--disable-features=${a}`))}catch{}return{logLevel:ix,desiredCapabilities:{chromeOptions:{args:i,extensions:n,binary:r},browserName:"chrome"},host:"localhost",port:9515}}async function px(){if(await Te(hc))try{let{webSocketDebuggerUrl:s}=await dx();await mx(s),await Le.promises.unlink(hc)}catch(s){s&&s.message==="unable to connect to devtools http server"&&await Le.promises.unlink(hc)}}async function dx(){let s=await Le.promises.readFile(hc,{encoding:"utf8"}),[e,t]=s.split(`
|
|
419
419
|
`).map(i=>i.trim()),r=Number.parseInt(e,10);if(!Number.isInteger(r)||r<1||r>65535)throw new Error("invalid port number");if(!t.startsWith("/devtools/browser/"))throw new Error("invalid devtools browser url");let n=await xr(`localhost:${r}`,500);if(!n.endsWith(t))throw new Error("invariant webSocketDebuggerUrl miss match");return{port:r,webSocketDebuggerUrl:n}}async function mx(s,e=100){let t=await fx(s,e);return nr(r=>{t.send(JSON.stringify({id:0,method:"Browser.close"}),r)})}async function fx(s,e=100){let t=Ja({timeout:e}),r=new yw.default(s,t),n=nr(o=>{r.once("open",o)}).then(()=>{r.removeAllListeners()}),i=nr(o=>{r.once("error",o)}).catch(()=>{r.close(),r.removeAllListeners()});return Promise.race([n,i]).then(()=>r)}var gw,hw,yw,Le,br,yc,ix,ox,qs,ax,hc,bw,_d=I(()=>{"use strict";gw=R(require("ms")),hw=R(require("ora")),yw=R(require("ws")),Le=R(require("node:fs")),br=R(require("node:path")),yc=R(require("chrome-launcher"));le();Tn();Q();Il();F();Go();Xa();ix=Oi?"verbose":"silent",ox=(0,gw.default)("1h"),qs=br.join(St,"profile"),ax="DevToolsActivePort",hc=br.join(qs,ax);bw=!1});var LM=require("source-map-support/register");var Ai=R(require("os")),Ks=R(require("url")),Js=R(require("http")),wc=R(require("https")),Si=R(require("form-data")),Ei=class{constructor(){this.onloadstart=null;this.onprogress=null;this.onabort=null;this.onerror=null;this.onload=null;this.ontimeout=null;this.onloadend=null;this._listeners={}}addEventListener(e,t){e=e.toLowerCase(),this._listeners[e]||=[],this._listeners[e].push(t)}removeEventListener(e,t){let r;e=e.toLowerCase(),this._listeners[e]&&(r=this._listeners[e].indexOf(t),r!==-1&&this._listeners[e].splice(r,1))}dispatchEvent(e){var n;e.currentTarget=this,e.target=this;let t=e.type,r=this._listeners[t]||[];for(let i of r)i==null||i.call(this,e);(n=this[`on${t}`])==null||n.call(this,e)}},Ii=class extends Ei{constructor(t){super();this._request=t;this._contentType=null;this._body=null}_reset(){this._contentType=null,this._body=null}_setData(t){if(t!=null)if(typeof t=="string")t.length!==0&&(this._contentType="text/plain;charset=UTF-8"),this._body=Buffer.from(t,"utf8");else if(Buffer.isBuffer(t))this._body=t;else if(t instanceof ArrayBuffer){let r=Buffer.alloc(t.byteLength),n=new Uint8Array(t);for(let i=0;i<t.byteLength;i++)r[i]=n[i];this._body=r}else if("buffer"in t&&t.buffer instanceof ArrayBuffer){let r=Buffer.alloc(t.byteLength),n=t.byteOffset,i=new Uint8Array(t.buffer);for(let o=0;o<t.byteLength;o++)r[o]=i[o+n];this._body=r}else if(typeof t=="object"&&t instanceof Si.default)this._body=null;else throw new Error(`Unsupported send() data ${t}`)}_finalizeHeaders(t,r){this._contentType&&!("content-type"in r)&&(t["Content-Type"]=this._contentType),this._body&&(t["Content-Length"]=this._body.length.toString())}_startUpload(t){this._body&&t.write(this._body),t.end()}},zs=class{constructor(e){this.type=e;this.target=null;this.currentTarget=null;this.lengthComputable=!1;this.loaded=0;this.total=0;this.bubbles=!1;this.cancelable=!1}},Ri=class extends Error{},xi=class extends Error{},Ci=class extends Error{},Tr=class extends Error{},Ae=class extends Ei{constructor(t){super();this.UNSENT=0;this.OPENED=1;this.HEADERS_RECEIVED=2;this.LOADING=3;this.DONE=4;this.nodejsHttpAgent=Js.globalAgent;this.nodejsHttpsAgent=wc.globalAgent;this.nodejsBaseUrl=null;this._restrictedMethods={CONNECT:!0,TRACE:!0,TRACK:!0};this._restrictedHeaders={"accept-charset":!0,"accept-encoding":!0,"access-control-request-headers":!0,"access-control-request-method":!0,connection:!0,"content-length":!0,cookie:!0,cookie2:!0,date:!0,dnt:!0,expect:!0,host:!0,"keep-alive":!0,origin:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,via:!0};this._privateHeaders={"set-cookie":!1,"set-cookie2":!1};this._userAgent=`Mozilla/5.0 (${Ai.type()} ${Ai.arch()}) node.js/${process.versions.node} v8/${process.versions.v8}`;this.onreadystatechange=null;this.readyState=Ae.UNSENT;this.response=null;this.responseText="";this.responseType="";this.status=0;this.statusText="";this.timeout=0;this.upload=new Ii(this);this._method=null;this._url=null;this._sync=!1;this._headers=null;this._loweredHeaders=null;this._mimeOverride=null;this._request=null;this._response=null;this._responseParts=null;this._responseHeaders=null;this._aborting=null;this._error=null;this._loadedBytes=0;this._totalBytes=0;this._lengthComputable=!1;this._anonymous=t==null?void 0:t.anon}static nodejsSet(t){Ae.prototype.nodejsSet(t)}nodejsSet(t){if("httpAgent"in t&&(this.nodejsHttpAgent=t.httpAgent),"httpsAgent"in t&&(this.nodejsHttpsAgent=t.httpsAgent),"baseUrl"in t){let r=t.baseUrl;if(r!==null&&!Ks.parse(r,!1,!0).protocol)throw new Ri("baseUrl must be an absolute URL");this.nodejsBaseUrl=r}}open(t,r,n){if(t=t.toUpperCase(),t in this._restrictedMethods)throw new Ci(`HTTP method ${t} is not allowed in XHR`);let i=this._parseUrl(r);n===void 0&&(n=!0),this._method=t,this._url=i,this._sync=!n,this._headers={},this._loweredHeaders={},this._mimeOverride=null,this._setReadyState(Ae.OPENED),this._request=null,this._response=null,this.status=0,this.statusText="",this._responseParts=[],this._responseHeaders=null,this._loadedBytes=0,this._totalBytes=0,this._lengthComputable=!1}setRequestHeader(t,r){if(this.readyState!==Ae.OPENED)throw new Tr("XHR readyState must be OPENED");let n=t.toLowerCase();this._restrictedHeaders[n]||n.startsWith("sec-")||n.startsWith("proxy-")||(r=r.toString(),n in this._loweredHeaders?(t=this._loweredHeaders[n],this._headers[t]=`${this._headers[t]}, ${r}`):(this._loweredHeaders[n]=t,this._headers[t]=r))}send(t){if(this.readyState!==Ae.OPENED)throw new Tr("XHR readyState must be OPENED");if(this._request)throw new Tr("send() already called");switch(this._url.protocol){case"file:":this._sendFile();break;case"http:":case"https:":this._sendHttp(t);break;default:throw new xi(`XHR request to ${this._url.href} failed: unsupported protocol '${this._url.protocol}'. Please use supported protocols like HTTP, HTTPS, or file.`)}}abort(){this._request&&(this._request.abort(),this._setError(),this._dispatchProgress("abort"),this._dispatchProgress("loadend"))}getResponseHeader(t){var n;let r=t.toLowerCase();return((n=this._responseHeaders)==null?void 0:n[r])||null}getAllResponseHeaders(){return this._responseHeaders?Object.entries(this._responseHeaders).map(([t,r])=>`${t}: ${r}`).join(`\r
|