shiplightai 0.1.70 → 0.1.71
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/dist/cjs/index.cjs +20 -20
- package/dist/cjs/reporter.cjs +1 -1
- package/dist/cli.js +16 -16
- package/dist/index.js +20 -20
- package/dist/reporter.js +1 -1
- package/package.json +2 -2
package/dist/reporter.js
CHANGED
|
@@ -883,7 +883,7 @@ import*as T from"fs";import*as v from"path";import{v4 as St}from"uuid";import{z
|
|
|
883
883
|
});
|
|
884
884
|
</script>
|
|
885
885
|
</body>
|
|
886
|
-
</html>`}var ke="0.1.
|
|
886
|
+
</html>`}var ke="0.1.71",Te=ke!=="dev"?ke:void 0;var bn=3600*1e3,wn=10080*60*1e3;var ht={before:0,main:1,teardown:2,after:3};function Ae(e){let t=e.split(".")[0];return ht[t]??1}function $e(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function ft(e){return[...e].sort(([t],[r])=>{let i=Ae(t),n=Ae(r);if(i!==n)return i-n;let a=$e(t),o=$e(r);for(let p=0;p<Math.max(a.length,o.length);p++){let c=a[p]??-1,f=o[p]??-1;if(c!==f)return c-f}return 0})}function mt(e){let t=new Set;for(let r of e)if(t.add(r.category),r.category==="hook")for(let i of r.steps)t.add(i.category);return t}function gt(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function q(e,t="main",r,i,n){r===void 0&&(r=!mt(e).has("test.step")),n||(n=new Map);let a=[];for(let o of e){if(o.category==="fixture"||o.category==="test.attach")continue;if(o.category==="hook"){let c=gt(o.title,t);a.push(...q(o.steps,c,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let c=n.get(t)??0;n.set(t,c+1);let f=`${t}.${c}`,w={stepId:f,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(w.error=o.error.message??o.error.stack),i&&o.location&&i.set(f,o.location),a.push(w),o.steps.length>0&&a.push(...q(o.steps,f,r,i,n))}}return a}var Z=class{outputFolder;openMode;collected=[];config;runStartTime;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure"}onBegin(t,r){this.config=t,this.runStartTime=new Date().toISOString()}onTestEnd(t,r){this.collected.push({test:t,result:r})}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let f of this.collected){let w=f.test.titlePath().join(" > "),b=r.get(w);b||(b=[],r.set(w,b)),b.push(f)}let i=[];for(let[,f]of r.entries()){let w=f[0].test.location.file,b=[],l,d,h;for(let g=0;g<f.length;g++){let{test:y,result:k}=f[g],A=await this.buildReportTest(y,k,w);l=A,d||(d=A.startTime),h=A.endTime,b.push({attemptNumber:g+1,status:k.status,duration:k.duration,steps:A.steps,error:A.error,videoPath:A.videoPath,tracePath:A.tracePath})}let u=b[b.length-1],{test:S}=f[f.length-1],_={title:S.title,baseTitle:l?.baseTitle,file:v.relative(process.cwd(),w),status:u.status,duration:u.duration,steps:u.steps,error:u.error,videoPath:u.videoPath,tracePath:u.tracePath,actionStepsMap:l?.actionStepsMap,tags:l?.tags,baseUrl:l?.baseUrl,skip:l?.skip,slow:l?.slow,timeout:l?.timeout,parameterSetName:l?.parameterSetName,startTime:d,endTime:h,suiteName:l?.suiteName};b.length>1&&(_.retries=b.length-1,_.attempts=b,b.some(y=>y.status==="failed"||y.status==="timedOut")&&u.status==="passed"&&(_.flaky=!0)),i.push(_)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:Te},a=v.isAbsolute(this.outputFolder)?this.outputFolder:v.join(process.cwd(),this.outputFolder);T.mkdirSync(a,{recursive:!0});let o=v.join(a,"screenshots");for(let f=0;f<n.tests.length;f++){let w=n.tests[f],b=w.attempts&&w.attempts.length>0,l=[{obj:w,prefix:b?`test-${f}-attempt-0`:`test-${f}`,screenshotSubDir:`test-${f}`}];if(w.attempts)for(let d=0;d<w.attempts.length;d++)l.push({obj:w.attempts[d],prefix:`test-${f}-attempt-${d+1}`,screenshotSubDir:`test-${f}/attempt-${d}`});for(let{obj:d,prefix:h,screenshotSubDir:u}of l){let S=v.join(o,u),_=!1;for(let g of d.steps)if(g.screenshot&&v.isAbsolute(g.screenshot))try{_||(T.mkdirSync(S,{recursive:!0}),_=!0);let y=`${g.stepId.replace(/\./g,"-")}.png`;T.copyFileSync(g.screenshot,v.join(S,y)),g.screenshot=`screenshots/${u}/${y}`}catch(y){console.warn(`[reporter] Failed to copy screenshot for ${g.stepId}:`,y)}if(d.videoPath&&v.isAbsolute(d.videoPath)){let g=v.extname(d.videoPath)||".webm",y=`${h}-video${g}`;try{T.copyFileSync(d.videoPath,v.join(a,y)),d.videoPath=y}catch{d.videoPath=void 0}}if(d.tracePath&&v.isAbsolute(d.tracePath)){let g=v.extname(d.tracePath)||".zip",y=`${h}-trace${g}`;try{T.copyFileSync(d.tracePath,v.join(a,y)),d.tracePath=y}catch{d.tracePath=void 0}}}}let p=v.join(a,"report-data.json");T.writeFileSync(p,JSON.stringify(n,null,2),"utf-8");let c=v.join(a,"index.html");if(T.writeFileSync(c,xe(n),"utf-8"),console.log(`
|
|
887
887
|
Shiplight report written to: ${c}`),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let f=(await import("open")).default;await f(c)}catch{}}printsToStdio(){return!1}async buildReportTest(t,r,i){let n={title:t.title,file:v.relative(process.cwd(),i),status:r.status,duration:r.duration,steps:[],startTime:new Date(r.startTime).toISOString(),endTime:new Date(r.startTime.getTime()+r.duration).toISOString()};r.errors.length>0&&(n.error=r.errors.map(l=>l.message||l.stack||String(l)).join(`
|
|
888
888
|
|
|
889
889
|
`)),r.stdout.length>0&&(n.stdout=r.stdout.map(l=>typeof l=="string"?l:l.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(l=>typeof l=="string"?l:l.toString()).join(""));for(let l of r.attachments)l.name==="video"&&l.path&&(n.videoPath=l.path),l.name==="trace"&&l.path&&(n.tracePath=l.path);let a=r.attachments.find(l=>l.name==="shiplight-results"),o=null;if(a)try{if(a.body)o=JSON.parse(a.body.toString("utf-8"));else if(a.path){let l=T.readFileSync(a.path,"utf-8");o=JSON.parse(l)}}catch{}let p=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),c={},f=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),w=f?f[1]:t.title,b=f?f[2]:void 0;if(b&&(n.parameterSetName=b),T.existsSync(p))try{let l=T.readFileSync(p,"utf-8"),d=_e(l,p);if(d.suite){let h=d.suite.tests.find(u=>u.name===w);h&&(c=K(h.testFlow),h.tags?.length&&(n.tags=h.tags),h.skip!==void 0&&(n.skip=h.skip),h.slow&&(n.slow=h.slow),h.timeout!==void 0&&(n.timeout=h.timeout),n.baseTitle=h.name||h.testFlow?.goal),n.suiteName=d.name,d.tags?.length&&(n.suiteTags=d.tags),d.use?.baseURL&&(n.baseUrl=d.use.baseURL)}else d.testFlow&&(c=K(d.testFlow),n.baseTitle=d.name||d.testFlow?.goal,d.tags?.length&&(n.tags=d.tags),d.use?.baseURL&&(n.baseUrl=d.use.baseURL))}catch{}if(o||Object.keys(c).length>0){let l=new Set([...Object.keys(c),...Object.keys(o||{})]),d=Array.from(l).map(u=>[u,null]),h=ft(d);for(let[u]of h){let S=c[u],_=o?.[u],g=S?.description;if(!g||g==="Action"||g==="Draft"){let k=S?.action_entity;g=k?.action_description||k?.action_data?.kwargs?.description||_?.description||u}let y={stepId:u,description:g,status:_?.status||"pending",duration:_?.duration};if(_?.message){let k=typeof _.message=="string"?_.message:JSON.stringify(_.message,null,2);_.status==="failure"?y.error=k:y.message=k}if(_?.screenshot){let k=_.screenshot,A=a?.path?v.dirname(a.path):"",O=v.isAbsolute(k)?k:v.join(A,k);T.existsSync(O)&&(y.screenshot=O)}_?.code&&(y.code=_.code),n.steps.push(y)}}if(o===null&&Object.keys(c).length===0&&!i.endsWith(".yaml.spec.ts")){let l=new Map;if(n.steps=q(r.steps,"main",void 0,l),n.steps.length>0){let d=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(h=>{let u=l.get(h.stepId),S;if(u?.file){if(!d.has(u.file))try{d.set(u.file,T.readFileSync(u.file,"utf-8").split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiplightai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.71",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shiplight CLI for running and debugging .test.yaml files",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
"tsup": "^8.3.5",
|
|
99
99
|
"typescript": "5.5.4",
|
|
100
100
|
"mcp-tools": "1.0.0",
|
|
101
|
+
"shiplight-tools": "1.0.0",
|
|
101
102
|
"sdk-core": "0.1.0",
|
|
102
103
|
"sdk-internal": "0.1.1",
|
|
103
|
-
"shiplight-tools": "1.0.0",
|
|
104
104
|
"shiplight-types": "0.1.0",
|
|
105
105
|
"@loggia/common": "1.0.0"
|
|
106
106
|
},
|