var c=class{async verify(n){throw new Error("TestVerificationStrategy.verify() must be implemented")}canVerify(n){throw new Error("TestVerificationStrategy.canVerify() must be implemented")}getName(){throw new Error("TestVerificationStrategy.getName() must be implemented")}getPriority(){return 0}};import{execSync as y}from"node:child_process";import{existsSync as h}from"node:fs";var d=class extends c{getName(){return"Playwright JSON Reporter"}getPriority(){return 100}canVerify(n){let{testFilePath:i}=n;return h(i)}async verify(n){let{testFilePath:i,cwd:g,timeout:m=3e4}=n;try{console.log(`\u{1F9EA} Running test: ${i}`);let o=`npx playwright test ${i} --reporter=json --timeout=${m}`,s=y(o,{cwd:g,encoding:"utf-8",stdio:["pipe","pipe","pipe"],timeout:m+1e4}),t=JSON.parse(s).stats||{};return{success:t.unexpected===0,passed:t.expected||0,failed:t.unexpected||0,error:null,errorDetails:null}}catch(o){let s=o.stdout||o.stderr||o.message;try{let r=JSON.parse(s),t=r.stats||{},e="Test execution failed";if(r.suites&&r.suites.length>0){let a=r.suites[0];if(a.specs&&a.specs.length>0){let u=a.specs[0];if(u.tests&&u.tests.length>0){let p=u.tests[0];if(p.results&&p.results.length>0){let x=p.results[0];x.error&&(e=x.error.message||e)}}}}let l=e.includes("Executable doesn't exist")||e.includes("browserType.launch")||e.includes("Please run the following command")||e.includes("npx playwright install")||s.includes("Executable doesn't exist")||s.includes("npx playwright install");return{success:!1,passed:t.expected||0,failed:t.unexpected||0,error:e,errorDetails:e,isEnvironmentError:l}}catch{let t=s.match(/Error: (.+)/),e=t?t[1]:"Test execution failed",l=e.includes("Executable doesn't exist")||e.includes("browserType.launch")||e.includes("Please run the following command")||e.includes("npx playwright install")||s.includes("Executable doesn't exist")||s.includes("npx playwright install");return{success:!1,passed:0,failed:1,error:e,errorDetails:e,isEnvironmentError:l}}}}},T=d;export{d as PlaywrightJsonVerificationStrategy,T as default};
