@testrelic/playwright-analytics 2.15.0 → 2.16.0-next.124

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.
@@ -1,5 +1,6 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
2
  import { expect as expect$1 } from '@playwright/test';
3
+ import './visual.cjs';
3
4
 
4
5
  /**
5
6
  * Config resolution with prototype pollution prevention.
@@ -20,11 +21,12 @@ interface ResolvedApiConfig {
20
21
  }
21
22
 
22
23
  /**
23
- * Assertion-aware `expect`. Inside a test that ran through this fixture, each
24
- * assertion on an API response is recorded and linked to its originating call,
25
- * so it surfaces in the cloud report's API workspace; outside one it behaves
26
- * exactly like Playwright's `expect`. Import THIS `expect` (not the one from
27
- * '@playwright/test') for API assertion capture.
24
+ * Two single-purpose layers, composed.
25
+ *
26
+ * The inner layer records API assertions. The outer one attaches DOM
27
+ * comparison to `toHaveScreenshot` and `toMatchVisualBaseline`, which is why
28
+ * visual assertions written with THIS `expect` report which elements changed
29
+ * while ones written with Playwright's own `expect` compare pixels only.
28
30
  */
29
31
  declare const expect: typeof expect$1;
30
32
  /**
package/dist/fixture.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
2
  import { expect as expect$1 } from '@playwright/test';
3
+ import './visual.js';
3
4
 
4
5
  /**
5
6
  * Config resolution with prototype pollution prevention.
@@ -20,11 +21,12 @@ interface ResolvedApiConfig {
20
21
  }
21
22
 
22
23
  /**
23
- * Assertion-aware `expect`. Inside a test that ran through this fixture, each
24
- * assertion on an API response is recorded and linked to its originating call,
25
- * so it surfaces in the cloud report's API workspace; outside one it behaves
26
- * exactly like Playwright's `expect`. Import THIS `expect` (not the one from
27
- * '@playwright/test') for API assertion capture.
24
+ * Two single-purpose layers, composed.
25
+ *
26
+ * The inner layer records API assertions. The outer one attaches DOM
27
+ * comparison to `toHaveScreenshot` and `toMatchVisualBaseline`, which is why
28
+ * visual assertions written with THIS `expect` report which elements changed
29
+ * while ones written with Playwright's own `expect` compare pixels only.
28
30
  */
29
31
  declare const expect: typeof expect$1;
30
32
  /**
package/dist/fixture.js CHANGED
@@ -1,5 +1,7 @@
1
- import {test,expect}from'@playwright/test';import {mkdirSync,openSync,writeSync,closeSync,unlinkSync,readFileSync}from'fs';import {join}from'path';import {tmpdir}from'os';import {randomUUID}from'crypto';import'readline';import {performance}from'perf_hooks';import {fileURLToPath}from'url';import {PAYLOAD_VERSION,ATTACHMENT_NAME,ATTACHMENT_CONTENT_TYPE}from'@testrelic/core';var H=join(tmpdir(),"testrelic-data"),m=class{constructor(e){this.count=0;this.closed=false;mkdirSync(H,{recursive:true}),this.filePath=join(H,`${e}-${randomUUID().substring(0,8)}.jsonl`),this.fd=openSync(this.filePath,"w");}append(e){if(this.closed)return;let t=JSON.stringify(e)+`
2
- `;writeSync(this.fd,t),this.count++;}getPath(){return this.filePath}getCount(){return this.count}close(){if(!this.closed){this.closed=true;try{closeSync(this.fd);}catch{}}}cleanup(){try{unlinkSync(this.filePath);}catch{}}};var ue=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function ce(r){let e=r.toLowerCase();return ue.some(t=>e.includes(t))}var A=class r{constructor(e,t){this.page=e;this.records=[];this.listeners=[];this.navCounters=[];this.pendingRequests=new Map;this.networkWriter=null;this.consoleWriter=null;this.pendingBodyReads=[];this.requestIdCounter=0;this.networkRequestCount=0;this.consoleLogCount=0;this.includeNetworkStats=t?.includeNetworkStats??true,this.origGoto=e.goto.bind(e),this.origGoBack=e.goBack.bind(e),this.origGoForward=e.goForward.bind(e),this.origReload=e.reload.bind(e);try{this.includeNetworkStats&&(this.networkWriter=new m("network")),this.consoleWriter=new m("console");}catch{}this.interceptMethods(),this.attachListeners();}async init(){await this.injectSPADetection();}async finalizeCapturedRequests(){await Promise.allSettled(this.pendingBodyReads),this.pendingBodyReads=[];for(let[,e]of this.pendingRequests)this.networkWriter&&(this.networkWriter.append({url:e.url,method:e.method,resourceType:e.resourceType,statusCode:0,responseTimeMs:Date.now()-e.startTimeMs,startedAt:e.startedAt,requestHeaders:e.headers,requestBody:e.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:e.postDataTruncated,responseBodyTruncated:false,isBinary:false,error:"incomplete"}),this.networkRequestCount++);this.pendingRequests.clear(),this.networkWriter?.close(),this.consoleWriter?.close();}static mapConsoleType(e){switch(e){case "log":return "log";case "warning":return "warn";case "error":return "error";case "info":return "info";case "debug":return "debug";default:return "log"}}async getFileData(){this.assembleNetworkStats();let e=this.records.map(t=>({url:t.url,navigationType:t.navigationType,timestamp:t.timestamp,domContentLoadedAt:t.domContentLoadedAt,networkIdleAt:t.networkIdleAt,networkStats:t.networkStats}));return this.includeNetworkStats?await this.finalizeCapturedRequests():this.consoleWriter?.close(),{navigations:e,networkRequestsFile:this.networkWriter?.getCount()?this.networkWriter.getPath():null,networkRequestsCount:this.networkWriter?.getCount()??0,consoleLogsFile:this.consoleWriter?.getCount()?this.consoleWriter.getPath():null,consoleLogsCount:this.consoleWriter?.getCount()??0}}async flushLegacyAnnotations(e){}dispose(){this.page.goto=this.origGoto,this.page.goBack=this.origGoBack,this.page.goForward=this.origGoForward,this.page.reload=this.origReload;for(let{event:e,handler:t}of this.listeners)this.page.off(e,t);this.listeners=[],this.records=[],this.pendingRequests.clear(),this.pendingBodyReads=[],this.networkWriter?.close(),this.consoleWriter?.close();}getRecords(){return this.assembleNetworkStats(),this.records}interceptMethods(){let e=this,t=this.page;t.goto=async function(n,s){return e.recordNavigation(n,"goto"),e.origGoto(n,s)},t.goBack=async function(n){let s=await e.origGoBack(n);return e.recordNavigation(t.url(),"back"),s},t.goForward=async function(n){let s=await e.origGoForward(n);return e.recordNavigation(t.url(),"forward"),s},t.reload=async function(n){return e.recordNavigation(t.url(),"refresh"),e.origReload(n)};}attachListeners(){let e=()=>{this.lastDomContentLoaded=new Date().toISOString(),this.records.length>0&&(this.records[this.records.length-1].domContentLoadedAt=this.lastDomContentLoaded);};this.page.on("domcontentloaded",e),this.listeners.push({event:"domcontentloaded",handler:e});let t=s=>{try{let o=s;if(typeof o.parentFrame=="function"&&o.parentFrame()!==null)return;let p=o.url(),l=this.records[this.records.length-1];if(l&&Date.now()-new Date(l.timestamp).getTime()<50&&l.url===p)return;this.recordNavigation(p,"navigation");}catch{}};this.page.on("framenavigated",t),this.listeners.push({event:"framenavigated",handler:t});let n=s=>{try{let o=s,p=o.type(),l=o.text();if(p==="debug"&&l.startsWith("__testrelic_nav:")){try{let c=JSON.parse(l.slice(16));c.type&&c.url&&this.recordNavigation(c.url,c.type);}catch{}return}{let c=null;try{let u=o.location();u&&u.url&&(c=`${u.url}:${u.lineNumber}:${u.columnNumber}`);}catch{}let a=r.mapConsoleType(p);this.consoleWriter&&(this.consoleWriter.append({level:a,text:l,timestamp:new Date().toISOString(),location:c}),this.consoleLogCount++);}}catch{}};if(this.page.on("console",n),this.listeners.push({event:"console",handler:n}),this.includeNetworkStats){let s=l=>{let c=this.records.length-1,a=this.counterForNav(c);a&&a.totalRequests++;try{let u=l,g=String(this.requestIdCounter++),d=u.postData()??null,i={url:u.url(),method:u.method(),resourceType:this.mapResourceType(u.resourceType()),headers:u.headers(),postData:d,postDataTruncated:!1,startedAt:new Date().toISOString(),startTimeMs:Date.now(),navIndex:c};this.pendingRequests.set(g,i),l.__testrelic_id=g;}catch{}};this.page.on("request",s),this.listeners.push({event:"request",handler:s});let o=l=>{try{let c=l,a=c.request().__testrelic_id,u=a?this.pendingRequests.get(a):void 0,g=this.counterForNav(u?u.navIndex:this.records.length-1);if(g){let f=c.status();f>=400&&(g.failedRequests++,g.failedRequestUrls.push(f+" "+c.url()));let y=c.headers()["content-length"];y&&(g.totalBytes+=parseInt(y,10)||0);let k=c.request().resourceType(),v=this.mapResourceType(k);g.byType[v]++;}if(!a||!u)return;this.pendingRequests.delete(a);let d=Date.now()-u.startTimeMs,i=c.headers(),h=i["content-type"]??null,R=parseInt(i["content-length"]??"0",10)||0,w=h?!ce(h):!1,T=(async()=>{let f=null;if(!w)try{f=(await c.body()).toString("utf-8");}catch{}let y={url:u.url,method:u.method,resourceType:u.resourceType,statusCode:c.status(),responseTimeMs:d,startedAt:u.startedAt,requestHeaders:u.headers,requestBody:u.postData,responseBody:f,responseHeaders:i,contentType:h,responseSize:R,requestBodyTruncated:u.postDataTruncated,responseBodyTruncated:!1,isBinary:w,error:null};this.networkWriter&&(this.networkWriter.append(y),this.networkRequestCount++);})();this.pendingBodyReads.push(T);}catch{}};this.page.on("response",o),this.listeners.push({event:"response",handler:o});let p=l=>{let c=l.__testrelic_id,a=c?this.pendingRequests.get(c):void 0,u=this.counterForNav(a?a.navIndex:this.records.length-1);if(u){u.failedRequests++;try{let g=l;u.failedRequestUrls.push("ERR "+g.url());}catch{}}try{let g=l;if(!c||!a)return;this.pendingRequests.delete(c);let d={url:a.url,method:a.method,resourceType:a.resourceType,statusCode:0,responseTimeMs:Date.now()-a.startTimeMs,startedAt:a.startedAt,requestHeaders:a.headers,requestBody:a.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:a.postDataTruncated,responseBodyTruncated:!1,isBinary:!1,error:g.failure()?.errorText??"Unknown error"};this.networkWriter&&(this.networkWriter.append(d),this.networkRequestCount++);}catch{}};this.page.on("requestfailed",p),this.listeners.push({event:"requestfailed",handler:p});}}async injectSPADetection(){try{await this.page.addInitScript(()=>{let e=history.pushState.bind(history),t=history.replaceState.bind(history);history.pushState=function(...n){e(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_route",url:location.href}));},history.replaceState=function(...n){t(...n),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_replace",url:location.href}));},window.addEventListener("popstate",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"popstate",url:location.href}));}),window.addEventListener("hashchange",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"hash_change",url:location.href}));});});}catch{}}recordNavigation(e,t){this.records.push({url:e,navigationType:t,timestamp:new Date().toISOString()}),this.includeNetworkStats&&this.navCounters.push(this.createNetworkCounter());}createNetworkCounter(){return {totalRequests:0,failedRequests:0,failedRequestUrls:[],totalBytes:0,byType:{xhr:0,document:0,script:0,stylesheet:0,image:0,font:0,other:0}}}counterForNav(e){return e>=0?this.navCounters[e]:void 0}assembleNetworkStats(){if(this.includeNetworkStats)for(let e=0;e<this.records.length;e++){let t=this.navCounters[e];t&&(this.records[e].networkStats={totalRequests:t.totalRequests,failedRequests:t.failedRequests,failedRequestUrls:[...t.failedRequestUrls],totalBytes:t.totalBytes,byType:{...t.byType}});}}mapResourceType(e){switch(e){case "xhr":case "fetch":return "xhr";case "document":return "document";case "script":return "script";case "stylesheet":return "stylesheet";case "image":return "image";case "font":return "font";default:return "other"}}};var I=Symbol.for("__testrelic_call_id"),pe="__testrelic_api_assertions",C=new WeakMap,b=class{constructor(){this.assertions=[];this.currentCallId=null;}recordAssertion(e){this.assertions.push(e);}getAssertions(){return this.assertions}setCurrentCallId(e){this.currentCallId=e;}getCurrentCallId(){return this.currentCallId}getData(){return [...this.assertions]}flushLegacyAnnotations(e){this.assertions.length!==0&&e.annotations.push({type:pe,description:JSON.stringify(this.assertions)});}dispose(){this.assertions=[],this.currentCallId=null;}},U=new Map;function ge(r){let e=U.get(r);if(e)return e;try{let t=r.startsWith("file://")?fileURLToPath(r):r,s=readFileSync(t,"utf-8").split(`
3
- `);return U.set(r,s),s}catch{return null}}function fe(){let e=new Error().stack;if(!e)return null;let t=e.split(`
4
- `);for(let n of t){if(n.includes("/assertion-tracker.")||n.includes("/api-request-tracker.")||n.includes("node:internal")||n.includes(" at new Error")||n.includes(" at captureAssertionLocation")||n.includes(" at expectWrapper")||n.includes(" at wrappedMatcher"))continue;let s=n.match(/at\s+(?:.*?\s+\()?(.+?):(\d+):(\d+)\)?$/);if(s)return {file:s[1],line:parseInt(s[2],10),column:parseInt(s[3],10)}}return null}function he(r,e){if(!r)return "custom";let t=r.toLowerCase();return t.includes(".status()")&&!t.includes(".statustext()")?t.includes(".ok()")?"statusOk":"status":t.includes(".ok()")?"statusOk":t.includes(".headers()")||t.includes(".headersarray()")?"header":t.includes("tomatchobject")||t.includes("toequal")?"bodyMatch":t.includes("tocontain")||t.includes("tostringcontaining")?"bodyContains":t.includes(".json()")||t.includes(".text()")?"bodyField":"custom"}function ye(r,e,t){let n=function(o,...p){let l=r(),c=e();if(!l||!c)return t(o,...p);let a=null;if(o!=null&&typeof o=="object"){let i=o[I];typeof i=="string"&&(a=i);}if(!a&&o!==null&&o!==void 0&&typeof o=="object"&&(a=C.get(o)??null),a||(a=c.getCallIdForValue(o)),a||(a=l.getCurrentCallId()),!a)return t(o,...p);let u=fe(),g;if(u){let i=ge(u.file);i&&u.line>0&&u.line<=i.length&&(g=i[u.line-1].trim());}let d=t(o,...p);return a?V(d,{tracker:l,callId:a,received:o,location:u??{file:"unknown",line:0},expression:g}):d};for(let s of Object.keys(t))n[s]=t[s];return n}var Y=null,$=null;function L(r,e){Y=r,$=e;}function z(r){return ye(()=>Y,()=>$,r)}function V(r,e){return new Proxy(r,{get(t,n,s){let o=Reflect.get(t,n,s);return typeof o!="function"||typeof n=="symbol"?o:n==="not"?V(o,e):function(...l){let c=l[0],a="passed",u=e.received,g=null;try{let d=o.apply(this??t,l);return d&&typeof d=="object"&&typeof d.then=="function"?d.then(()=>{N(e,n,c,u,"passed");},i=>{throw N(e,n,c,u,"failed"),i}):d}catch(d){if(a="failed",g=d,d instanceof Error&&d.message){let i=d.message.match(/Received:\s*(.+)/);i&&(u=i[1]);}throw d}finally{(g!==null||a==="passed")&&N(e,n,c,u,a);}}}})}function N(r,e,t,n,s){let o=he(r.expression,r.received),p={callId:r.callId,type:o,expected:G(t),actual:G(n),status:s,location:r.location,expression:r.expression};r.tracker.recordAssertion(p);}function G(r){if(r==null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;try{return JSON.stringify(r),r}catch{return String(r)}}var K="[REDACTED]";function F(r,e){if(r===null||e.length===0)return r;let t=new Set(e.map(s=>s.toLowerCase())),n={};for(let s of Object.keys(r))Object.hasOwn(r,s)&&(n[s]=t.has(s.toLowerCase())?K:r[s]);return n}function q(r,e){if(r===null||e.length===0)return r;let t;try{t=JSON.parse(r);}catch{return r}if(typeof t!="object"||t===null)return r;let n=new Set(e.map(o=>o.toLowerCase())),s=B(t,n);return JSON.stringify(s)}function B(r,e){if(Array.isArray(r))return r.map(t=>B(t,e));if(typeof r=="object"&&r!==null){let t={};for(let n of Object.keys(r)){if(!Object.hasOwn(r,n))continue;let s=r[n];e.has(n.toLowerCase())?t[n]=K:t[n]=B(s,e);}return t}return r}var ke=new Set(["access_token","api_key","token","sig"]);function O(r){if(!r)return r;let e;try{e=new URL(r);}catch{return r}let t=false;for(let n of [...e.searchParams.keys()])ke.has(n.toLowerCase())&&(e.searchParams.delete(n),t=true);return t?e.toString():r}function X(r,e,t){if(t.length>0){for(let n of t)if(Q(r,n))return false}if(e.length>0){for(let n of e)if(Q(r,n))return true;return false}return true}function Q(r,e){try{return e instanceof RegExp?e.test(r):we(e).test(r)}catch{return console.warn(`[testrelic] Invalid URL filter pattern: ${String(e)}`),false}}function we(r){let e="",t=0;for(;t<r.length;){let n=r[t];n==="*"&&r[t+1]==="*"?(e+=".*",t+=2,r[t]==="/"&&t++):n==="*"?(e+="[^/]*",t++):n==="?"?(e+="[^/]",t++):".+^${}()|[]\\".includes(n)?(e+="\\"+n,t++):(e+=n,t++);}return new RegExp(e)}var me=["get","post","put","patch","delete","head","fetch"],Ce=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function Re(r){let e=r.toLowerCase();return Ce.some(t=>e.includes(t))}function Te(r){if(!r)return null;if(r.data!==void 0&&r.data!==null){let e=r.data;return typeof e=="string"?e:Buffer.isBuffer(e)?e.toString("base64"):JSON.stringify(e)}if(r.form!==void 0&&r.form!==null)return JSON.stringify(r.form);if(r.multipart!==void 0&&r.multipart!==null){let e=r.multipart,t={};for(let[n,s]of Object.entries(e))typeof s=="string"||typeof s=="number"||typeof s=="boolean"?t[n]=String(s):s&&typeof s=="object"&&"name"in s?t[n]=`[file: ${s.name}]`:t[n]="[binary]";return JSON.stringify(t)}return null}function Z(r){return r?"\u2022\u2022\u2022\u2022":""}function ve(r){if(!r)return [];let e;for(let[n,s]of Object.entries(r))if(n.toLowerCase()==="cookie"){e=s;break}if(!e)return [];let t=[];for(let n of e.split(";")){let s=n.trim();if(!s)continue;let o=s.indexOf("="),p=o===-1?s:s.slice(0,o).trim(),l=o===-1?"":s.slice(o+1).trim();p&&t.push({name:p,value:Z(l)});}return t}function Ae(r){let e=[];for(let t of r)for(let n of t.split(/,(?=\s*[A-Za-z0-9_.\-]+=)/)){let s=n.trim();if(!s)continue;let o=s.split(";"),p=o[0].indexOf("=");if(p===-1)continue;let l=o[0].slice(0,p).trim(),c=o[0].slice(p+1).trim(),a=o.slice(1).map(u=>u.trim()).filter(Boolean).join(" \xB7 ")||void 0;l&&e.push({name:l,value:Z(c),attributes:a});}return e}var S=class S{constructor(e,t,n){this.originals=new Map;this.apiCallWriter=null;this.callCounter=0;this.apiCallCount=0;this.disposed=false;this._lastCallId=null;this.primitiveCallIds=new Map;this.context=e,this.assertionTracker=t??null,this.apiConfig=n??S.DEFAULT_API_CONFIG;try{this.apiCallWriter=new m("api-calls");}catch{}}get lastCallId(){return this._lastCallId}getCallIdForValue(e){return e!=null&&typeof e=="object"?C.get(e)??null:this.primitiveCallIds.get(e)??null}intercept(){for(let t of me){let n=this.context[t].bind(this.context);this.originals.set(t,n),this.context[t]=this.createWrapper(t,n);}let e=this.context.dispose.bind(this.context);this.originals.set("dispose",e),this.context.dispose=async t=>(this.disposed=true,e(t));}getFileData(){return this.apiCallWriter?.close(),{apiCallsFile:this.apiCallWriter?.getCount()?this.apiCallWriter.getPath():null,apiCallsCount:this.apiCallWriter?.getCount()??0}}flushLegacyAnnotations(e){}dispose(){for(let[e,t]of this.originals)this.context[e]=t;this.originals.clear(),this.apiCallWriter?.close(),this.callCounter=0,this.apiCallCount=0,this._lastCallId=null,this.primitiveCallIds.clear();}get isDisposed(){return this.disposed}getCapturedCallCount(){return this.apiCallCount}tagResponseMethods(e,t){let n=this,s=e.headers.bind(e);e.headers=function(){let i=s();return C.set(i,t),i};let o=e.headersArray.bind(e);e.headersArray=function(){let i=o();return C.set(i,t),i};let p=e.json.bind(e);e.json=async function(){let i=await p();return i!=null&&typeof i=="object"&&C.set(i,t),i};let l=e.status.bind(e);e.status=function(){let i=l();return n.primitiveCallIds.set(i,t),i};let c=e.statusText.bind(e);e.statusText=function(){let i=c();return n.primitiveCallIds.set(i,t),i};let a=e.ok.bind(e);e.ok=function(){let i=a();return n.primitiveCallIds.set(i,t),i};let u=e.text.bind(e);e.text=async function(){let i=await u();return n.primitiveCallIds.set(i,t),i};let g=e.body.bind(e);e.body=async function(){let i=await g();return C.set(i,t),i};}createWrapper(e,t){let n=this;return async function(o,p){if(!X(o,n.apiConfig.apiIncludeUrls,n.apiConfig.apiExcludeUrls))return t(o,p);let l=`api-call-${n.callCounter++}`,c=new Date().toISOString(),a=e==="fetch"?(p?.method??"GET").toUpperCase():e.toUpperCase(),u=Te(p),g=performance.now();n._lastCallId=l,n.assertionTracker&&n.assertionTracker.setCurrentCallId(l);let d;try{d=await t(o,p);}catch(i){let h=performance.now();try{let R=n.apiConfig.captureRequestBody?q(u,n.apiConfig.redactBodyFields):null,w={id:l,timestamp:c,method:a,url:O(o),requestHeaders:null,requestBody:R,responseStatusCode:null,responseStatusText:null,responseHeaders:null,responseBody:null,responseTimeMs:Math.round((h-g)*100)/100,isBinary:!1,error:i instanceof Error?i.message:String(i)};n.apiCallWriter&&(n.apiCallWriter.append(w),n.apiCallCount++);}catch{}throw i}try{let i=performance.now(),h=d.headers(),R=h["content-type"]??null,w=R?!Re(R):!1,T=null;n.apiConfig.captureRequestHeaders&&p?.headers&&(T=p.headers);let f=null;n.apiConfig.captureResponseHeaders&&(f=h);let y=n.apiConfig.captureRequestBody?u:null,k=null;if(n.apiConfig.captureResponseBody)try{w?k=(await d.body()).toString("base64"):k=await d.text();}catch{}let v=[],_=[];try{if(n.apiConfig.captureRequestHeaders&&(v=ve(p?.headers)),n.apiConfig.captureResponseHeaders){let j=d.headersArray().filter(P=>P.name.toLowerCase()==="set-cookie").map(P=>P.value);_=Ae(j);}}catch{}T=F(T,n.apiConfig.redactHeaders),f=F(f,n.apiConfig.redactHeaders),y=q(y,n.apiConfig.redactBodyFields),k=q(k,n.apiConfig.redactBodyFields);let ee={id:l,timestamp:c,method:a,url:O(d.url()),requestHeaders:T,requestBody:y,responseStatusCode:d.status(),responseStatusText:d.statusText(),responseHeaders:f,responseBody:k,requestCookies:v.length?v:null,responseCookies:_.length?_:null,responseTimeMs:Math.round((i-g)*100)/100,isBinary:w,error:null};n.apiCallWriter&&(n.apiCallWriter.append(ee),n.apiCallCount++);}catch{}try{d[I]=l,n.tagResponseMethods(d,l);}catch{}return d}}};S.DEFAULT_API_CONFIG=Object.freeze({trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]});var x=S;var st=z(expect),xe="__testrelic_api_config",Se="__testrelic_config_trackApiCalls";function _e(r){let e=r.annotations.find(n=>n.type===xe&&n.description!==void 0);if(e)try{return JSON.parse(e.description,Pe)}catch{}let t=r.annotations.find(n=>n.type===Se&&n.description!==void 0);return t?{trackApiCalls:t.description!=="false",captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}:{trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}}function Pe(r,e){if(typeof e=="object"&&e!==null&&e.__regexp===true&&typeof e.source=="string"){let{source:t,flags:n}=e;return new RegExp(t,n)}return e}var Ne={page:async({page:r},e,t)=>{let n=new A(r);try{await n.init();}catch{}await e(r);try{let{navigations:s,networkRequestsFile:o,networkRequestsCount:p,consoleLogsFile:l,consoleLogsCount:c}=await n.getFileData(),a={testRelicData:!0,version:PAYLOAD_VERSION,navigations:s,apiAssertions:[],networkRequestsFile:o,networkRequestsCount:p,consoleLogsFile:l,consoleLogsCount:c,apiCallsFile:null,apiCallsCount:0};await t.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(a)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}n.dispose();},request:async({request:r},e,t)=>{let n=_e(t);if(!n.trackApiCalls){await e(r);return}let s=new b,o=new x(r,s,n);o.intercept(),L(s,o);try{await e(r);}finally{L(null,null);}try{let{apiCallsFile:p,apiCallsCount:l}=o.getFileData(),c=n.captureAssertions?s.getData():[],a={testRelicData:!0,version:PAYLOAD_VERSION,navigations:[],apiAssertions:c,networkRequestsFile:null,networkRequestsCount:0,consoleLogsFile:null,consoleLogsCount:0,apiCallsFile:p,apiCallsCount:l};await t.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(a)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}o.dispose(),s.dispose();}};async function ot(r,e){let t=new A(r);try{await t.init();}catch{}return async()=>{try{let{navigations:n,networkRequestsFile:s,networkRequestsCount:o,consoleLogsFile:p,consoleLogsCount:l}=await t.getFileData(),c={testRelicData:!0,version:PAYLOAD_VERSION,navigations:n,apiAssertions:[],networkRequestsFile:s,networkRequestsCount:o,consoleLogsFile:p,consoleLogsCount:l,apiCallsFile:null,apiCallsCount:0};await e.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(c)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}t.dispose();}}var it=test.extend(Ne);export{st as expect,_e as readApiConfig,it as test,Ne as testRelicFixture,ot as trackPage};//# sourceMappingURL=fixture.js.map
1
+ import {expect,test}from'@playwright/test';import {writeFileSync,existsSync,mkdirSync,openSync,writeSync,closeSync,unlinkSync,readFileSync}from'fs';import {join,extname,basename,dirname}from'path';import {tmpdir}from'os';import {randomUUID}from'crypto';import'readline';import {performance}from'perf_hooks';import {fileURLToPath}from'url';import {PAYLOAD_VERSION,ATTACHMENT_NAME,ATTACHMENT_CONTENT_TYPE}from'@testrelic/core';var lt=join(tmpdir(),"testrelic-data"),N=class{constructor(t){this.count=0;this.closed=false;mkdirSync(lt,{recursive:true}),this.filePath=join(lt,`${t}-${randomUUID().substring(0,8)}.jsonl`),this.fd=openSync(this.filePath,"w");}append(t){if(this.closed)return;let n=JSON.stringify(t)+`
2
+ `;writeSync(this.fd,n),this.count++;}getPath(){return this.filePath}getCount(){return this.count}close(){if(!this.closed){this.closed=true;try{closeSync(this.fd);}catch{}}}cleanup(){try{unlinkSync(this.filePath);}catch{}}};var Gt=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function $t(e){let t=e.toLowerCase();return Gt.some(n=>t.includes(n))}var B=class e{constructor(t,n){this.page=t;this.records=[];this.listeners=[];this.navCounters=[];this.pendingRequests=new Map;this.networkWriter=null;this.consoleWriter=null;this.pendingBodyReads=[];this.requestIdCounter=0;this.networkRequestCount=0;this.consoleLogCount=0;this.includeNetworkStats=n?.includeNetworkStats??true,this.origGoto=t.goto.bind(t),this.origGoBack=t.goBack.bind(t),this.origGoForward=t.goForward.bind(t),this.origReload=t.reload.bind(t);try{this.includeNetworkStats&&(this.networkWriter=new N("network")),this.consoleWriter=new N("console");}catch{}this.interceptMethods(),this.attachListeners();}async init(){await this.injectSPADetection();}async finalizeCapturedRequests(){await Promise.allSettled(this.pendingBodyReads),this.pendingBodyReads=[];for(let[,t]of this.pendingRequests)this.networkWriter&&(this.networkWriter.append({url:t.url,method:t.method,resourceType:t.resourceType,statusCode:0,responseTimeMs:Date.now()-t.startTimeMs,startedAt:t.startedAt,requestHeaders:t.headers,requestBody:t.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:t.postDataTruncated,responseBodyTruncated:false,isBinary:false,error:"incomplete"}),this.networkRequestCount++);this.pendingRequests.clear(),this.networkWriter?.close(),this.consoleWriter?.close();}static mapConsoleType(t){switch(t){case "log":return "log";case "warning":return "warn";case "error":return "error";case "info":return "info";case "debug":return "debug";default:return "log"}}async getFileData(){this.assembleNetworkStats();let t=this.records.map(n=>({url:n.url,navigationType:n.navigationType,timestamp:n.timestamp,domContentLoadedAt:n.domContentLoadedAt,networkIdleAt:n.networkIdleAt,networkStats:n.networkStats}));return this.includeNetworkStats?await this.finalizeCapturedRequests():this.consoleWriter?.close(),{navigations:t,networkRequestsFile:this.networkWriter?.getCount()?this.networkWriter.getPath():null,networkRequestsCount:this.networkWriter?.getCount()??0,consoleLogsFile:this.consoleWriter?.getCount()?this.consoleWriter.getPath():null,consoleLogsCount:this.consoleWriter?.getCount()??0}}async flushLegacyAnnotations(t){}dispose(){let t=e.asPatchable(this.page);t.goto=this.origGoto,t.goBack=this.origGoBack,t.goForward=this.origGoForward,t.reload=this.origReload;for(let{event:n,handler:r}of this.listeners)this.page.off(n,r);this.listeners=[],this.records=[],this.pendingRequests.clear(),this.pendingBodyReads=[],this.networkWriter?.close(),this.consoleWriter?.close();}getRecords(){return this.assembleNetworkStats(),this.records}static asPatchable(t){return t}interceptMethods(){let t=this,n=this.page,r=e.asPatchable(n);r.goto=async function(o,s){return t.recordNavigation(o,"goto"),t.origGoto(o,s)},r.goBack=async function(o){let s=await t.origGoBack(o);return t.recordNavigation(n.url(),"back"),s},r.goForward=async function(o){let s=await t.origGoForward(o);return t.recordNavigation(n.url(),"forward"),s},r.reload=async function(o){return t.recordNavigation(n.url(),"refresh"),t.origReload(o)};}attachListeners(){let t=()=>{this.lastDomContentLoaded=new Date().toISOString(),this.records.length>0&&(this.records[this.records.length-1].domContentLoadedAt=this.lastDomContentLoaded);};this.page.on("domcontentloaded",t),this.listeners.push({event:"domcontentloaded",handler:t});let n=o=>{try{let s=o;if(typeof s.parentFrame=="function"&&s.parentFrame()!==null)return;let c=s.url(),i=this.records[this.records.length-1];if(i&&Date.now()-new Date(i.timestamp).getTime()<50&&i.url===c)return;this.recordNavigation(c,"navigation");}catch{}};this.page.on("framenavigated",n),this.listeners.push({event:"framenavigated",handler:n});let r=o=>{try{let s=o,c=s.type(),i=s.text();if(c==="debug"&&i.startsWith("__testrelic_nav:")){try{let l=JSON.parse(i.slice(16));l.type&&l.url&&this.recordNavigation(l.url,l.type);}catch{}return}{let l=null;try{let f=s.location();f&&f.url&&(l=`${f.url}:${f.lineNumber}:${f.columnNumber}`);}catch{}let p=e.mapConsoleType(c);this.consoleWriter&&(this.consoleWriter.append({level:p,text:i,timestamp:new Date().toISOString(),location:l}),this.consoleLogCount++);}}catch{}};if(this.page.on("console",r),this.listeners.push({event:"console",handler:r}),this.includeNetworkStats){let o=i=>{let l=this.records.length-1,p=this.counterForNav(l);p&&p.totalRequests++;try{let f=i,u=String(this.requestIdCounter++),a=f.postData()??null,d={url:f.url(),method:f.method(),resourceType:this.mapResourceType(f.resourceType()),headers:f.headers(),postData:a,postDataTruncated:!1,startedAt:new Date().toISOString(),startTimeMs:Date.now(),navIndex:l};this.pendingRequests.set(u,d),i.__testrelic_id=u;}catch{}};this.page.on("request",o),this.listeners.push({event:"request",handler:o});let s=i=>{try{let l=i,p=l.request().__testrelic_id,f=p?this.pendingRequests.get(p):void 0,u=this.counterForNav(f?f.navIndex:this.records.length-1);if(u){let x=l.status();x>=400&&(u.failedRequests++,u.failedRequestUrls.push(x+" "+l.url()));let R=l.headers()["content-length"];R&&(u.totalBytes+=parseInt(R,10)||0);let A=l.request().resourceType(),v=this.mapResourceType(A);u.byType[v]++;}if(!p||!f)return;this.pendingRequests.delete(p);let a=Date.now()-f.startTimeMs,d=l.headers(),g=d["content-type"]??null,h=parseInt(d["content-length"]??"0",10)||0,w=g?!$t(g):!1,k=(async()=>{let x=null;if(!w)try{x=(await l.body()).toString("utf-8");}catch{}let R={url:f.url,method:f.method,resourceType:f.resourceType,statusCode:l.status(),responseTimeMs:a,startedAt:f.startedAt,requestHeaders:f.headers,requestBody:f.postData,responseBody:x,responseHeaders:d,contentType:g,responseSize:h,requestBodyTruncated:f.postDataTruncated,responseBodyTruncated:!1,isBinary:w,error:null};this.networkWriter&&(this.networkWriter.append(R),this.networkRequestCount++);})();this.pendingBodyReads.push(k);}catch{}};this.page.on("response",s),this.listeners.push({event:"response",handler:s});let c=i=>{let l=i.__testrelic_id,p=l?this.pendingRequests.get(l):void 0,f=this.counterForNav(p?p.navIndex:this.records.length-1);if(f){f.failedRequests++;try{let u=i;f.failedRequestUrls.push("ERR "+u.url());}catch{}}try{let u=i;if(!l||!p)return;this.pendingRequests.delete(l);let a={url:p.url,method:p.method,resourceType:p.resourceType,statusCode:0,responseTimeMs:Date.now()-p.startTimeMs,startedAt:p.startedAt,requestHeaders:p.headers,requestBody:p.postData,responseBody:null,responseHeaders:null,contentType:null,responseSize:0,requestBodyTruncated:p.postDataTruncated,responseBodyTruncated:!1,isBinary:!1,error:u.failure()?.errorText??"Unknown error"};this.networkWriter&&(this.networkWriter.append(a),this.networkRequestCount++);}catch{}};this.page.on("requestfailed",c),this.listeners.push({event:"requestfailed",handler:c});}}async injectSPADetection(){try{await this.page.addInitScript(()=>{let t=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=function(...r){t(...r),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_route",url:location.href}));},history.replaceState=function(...r){n(...r),console.debug("__testrelic_nav:"+JSON.stringify({type:"spa_replace",url:location.href}));},window.addEventListener("popstate",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"popstate",url:location.href}));}),window.addEventListener("hashchange",()=>{console.debug("__testrelic_nav:"+JSON.stringify({type:"hash_change",url:location.href}));});});}catch{}}recordNavigation(t,n){this.records.push({url:t,navigationType:n,timestamp:new Date().toISOString()}),this.includeNetworkStats&&this.navCounters.push(this.createNetworkCounter());}createNetworkCounter(){return {totalRequests:0,failedRequests:0,failedRequestUrls:[],totalBytes:0,byType:{xhr:0,document:0,script:0,stylesheet:0,image:0,font:0,other:0}}}counterForNav(t){return t>=0?this.navCounters[t]:void 0}assembleNetworkStats(){if(this.includeNetworkStats)for(let t=0;t<this.records.length;t++){let n=this.navCounters[t];n&&(this.records[t].networkStats={totalRequests:n.totalRequests,failedRequests:n.failedRequests,failedRequestUrls:[...n.failedRequestUrls],totalBytes:n.totalBytes,byType:{...n.byType}});}}mapResourceType(t){switch(t){case "xhr":case "fetch":return "xhr";case "document":return "document";case "script":return "script";case "stylesheet":return "stylesheet";case "image":return "image";case "font":return "font";default:return "other"}}};var Xt=new RegExp("[\x1B\x9B][[\\]()#;?]*(?:\\d{1,4}(?:;\\d{0,4})*)?[0-9A-PR-TZcf-nqry=><]","g");function pt(e){return !e||e.indexOf("\x1B")===-1&&e.indexOf("\x9B")===-1?e:e.replace(Xt,"")}var U=Symbol.for("__testrelic_call_id"),Kt="__testrelic_api_assertions",D=new WeakMap,E=class{constructor(){this.assertions=[];this.currentCallId=null;}recordAssertion(t){this.assertions.push(t);}getAssertions(){return this.assertions}setCurrentCallId(t){this.currentCallId=t;}getCurrentCallId(){return this.currentCallId}getData(){return [...this.assertions]}flushLegacyAnnotations(t){this.assertions.length!==0&&t.annotations.push({type:Kt,description:JSON.stringify(this.assertions)});}dispose(){this.assertions=[],this.currentCallId=null;}},ft=new Map;function Zt(e){let t=ft.get(e);if(t)return t;try{let n=e.startsWith("file://")?fileURLToPath(e):e,o=readFileSync(n,"utf-8").split(`
3
+ `);return ft.set(e,o),o}catch{return null}}var gt=(()=>{let e=new Error().stack;if(!e)return null;for(let t of e.split(`
4
+ `)){let n=t.match(/at\s+(?:.*?\s+\()?(.+?):\d+:\d+\)?$/);if(!n||n[1].startsWith("node:"))continue;let r=Math.max(n[1].lastIndexOf("/"),n[1].lastIndexOf("\\"));return r>0?n[1].slice(0,r+1):null}return null})();function Qt(e){if(!e.startsWith("file:"))return e;try{return fileURLToPath(e)}catch{return e}}function te(){let t=new Error().stack;if(!t)return null;let n=t.split(`
5
+ `);return ht(n,true)??ht(n,false)}function ht(e,t){for(let n of e){if(t&&gt!==null&&n.includes(gt)||n.includes("node_modules")||n.includes("node:internal")||n.includes(" at new Error")||n.includes(" at captureAssertionLocation")||n.includes(" at findFrame")||n.includes(" at expectWrapper")||n.includes(" at wrappedMatcher"))continue;let r=n.match(/at\s+(?:.*?\s+\()?(.+?):(\d+):(\d+)\)?$/);if(r)return {file:Qt(r[1]),line:parseInt(r[2],10),column:parseInt(r[3],10)}}return null}function ee(e,t){if(!e)return "custom";let n=e.toLowerCase();return n.includes(".status()")&&!n.includes(".statustext()")?n.includes(".ok()")?"statusOk":"status":n.includes(".ok()")?"statusOk":n.includes(".headers()")||n.includes(".headersarray()")?"header":n.includes("tomatchobject")||n.includes("toequal")?"bodyMatch":n.includes("tocontain")||n.includes("tostringcontaining")?"bodyContains":n.includes(".json()")||n.includes(".text()")?"bodyField":"custom"}function ne(e,t,n){let r=function(i,...l){let p=e(),f=t();if(!p||!f)return n(i,...l);let u=null;if(i!=null&&typeof i=="object"){let h=i[U];typeof h=="string"&&(u=h);}if(!u&&i!==null&&i!==void 0&&typeof i=="object"&&(u=D.get(i)??null),u||(u=f.getCallIdForValue(i)),u||(u=p.getCurrentCallId()),!u)return n(i,...l);let a=te(),d;if(a){let h=Zt(a.file);h&&a.line>0&&a.line<=h.length&&(d=h[a.line-1].trim());}let g=n(i,...l);return u?bt(g,{tracker:p,callId:u,received:i,location:a??{file:"unknown",line:0},expression:d}):g},o=n,s=r;for(let c of Object.keys(o))s[c]=o[c];return r}var mt=Symbol.for("testrelic.activeAssertionContext");function V(){let e=globalThis,t=e[mt];return t||(t={tracker:null,apiTracker:null},e[mt]=t),t}function z(e,t){let n=V();n.tracker=e,n.apiTracker=t;}function kt(e){return ne(()=>V().tracker,()=>V().apiTracker,e)}function bt(e,t){return new Proxy(e,{get(n,r,o){let s=Reflect.get(n,r,o);return typeof s!="function"||typeof r=="symbol"?s:r==="not"?bt(s,t):function(...i){let l=i[0],p="passed",f=t.received,u=null;try{let a=s.apply(this??n,i);return a&&typeof a=="object"&&typeof a.then=="function"?a.then(()=>{W(t,r,l,f,"passed");},d=>{throw W(t,r,l,f,"failed"),d}):a}catch(a){if(p="failed",u=a,a instanceof Error&&a.message){let d=a.message.match(/Received:\s*(.+)/);d&&(f=d[1]);}throw a}finally{(u!==null||p==="passed")&&W(t,r,l,f,p);}}}})}function W(e,t,n,r,o){let s=ee(e.expression,e.received),c={callId:e.callId,type:s,expected:yt(n),actual:yt(r),status:o,location:e.location,expression:e.expression};e.tracker.recordAssertion(c);}function yt(e){if(e==null)return e;if(typeof e=="string")return pt(e);if(typeof e=="number"||typeof e=="boolean")return e;try{return JSON.stringify(e),e}catch{return String(e)}}var xt="[REDACTED]";function G(e,t){if(e===null||t.length===0)return e;let n=new Set(t.map(o=>o.toLowerCase())),r={};for(let o of Object.keys(e))Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=n.has(o.toLowerCase())?xt:e[o]);return r}function I(e,t){if(e===null||t.length===0)return e;let n;try{n=JSON.parse(e);}catch{return e}if(typeof n!="object"||n===null)return e;let r=new Set(t.map(s=>s.toLowerCase())),o=J(n,r);return JSON.stringify(o)}function J(e,t){if(Array.isArray(e))return e.map(n=>J(n,t));if(typeof e=="object"&&e!==null){let n={};for(let r of Object.keys(e)){if(!Object.prototype.hasOwnProperty.call(e,r))continue;let o=e[r];t.has(r.toLowerCase())?n[r]=xt:n[r]=J(o,t);}return n}return e}var re=new Set(["access_token","api_key","token","sig"]);function $(e){if(!e)return e;let t;try{t=new URL(e);}catch{return e}let n=false;for(let r of [...t.searchParams.keys()])re.has(r.toLowerCase())&&(t.searchParams.delete(r),n=true);return n?t.toString():e}function Rt(e,t,n){if(n.length>0){for(let r of n)if(Ct(e,r))return false}if(t.length>0){for(let r of t)if(Ct(e,r))return true;return false}return true}function Ct(e,t){try{return t instanceof RegExp?t.test(e):oe(t).test(e)}catch{return console.warn(`[testrelic] Invalid URL filter pattern: ${String(t)}`),false}}function oe(e){let t="",n=0;for(;n<e.length;){let r=e[n];r==="*"&&e[n+1]==="*"?(t+=".*",n+=2,e[n]==="/"&&n++):r==="*"?(t+="[^/]*",n++):r==="?"?(t+="[^/]",n++):".+^${}()|[]\\".includes(r)?(t+="\\"+r,n++):(t+=r,n++);}return new RegExp(t)}var se=["get","post","put","patch","delete","head","fetch"],ie=["text/","application/json","application/xml","application/javascript","application/x-www-form-urlencoded","application/graphql"];function ae(e){let t=e.toLowerCase();return ie.some(n=>t.includes(n))}function ue(e){if(!e)return null;if(e.data!==void 0&&e.data!==null){let t=e.data;return typeof t=="string"?t:Buffer.isBuffer(t)?t.toString("base64"):JSON.stringify(t)}if(e.form!==void 0&&e.form!==null)return JSON.stringify(e.form);if(e.multipart!==void 0&&e.multipart!==null){let t=e.multipart,n={};for(let[r,o]of Object.entries(t))typeof o=="string"||typeof o=="number"||typeof o=="boolean"?n[r]=String(o):o&&typeof o=="object"&&"name"in o?n[r]=`[file: ${o.name}]`:n[r]="[binary]";return JSON.stringify(n)}return null}function Tt(e){return e?"\u2022\u2022\u2022\u2022":""}function ce(e){if(!e)return [];let t;for(let[r,o]of Object.entries(e))if(r.toLowerCase()==="cookie"){t=o;break}if(!t)return [];let n=[];for(let r of t.split(";")){let o=r.trim();if(!o)continue;let s=o.indexOf("="),c=s===-1?o:o.slice(0,s).trim(),i=s===-1?"":o.slice(s+1).trim();c&&n.push({name:c,value:Tt(i)});}return n}function le(e){let t=[];for(let n of e)for(let r of n.split(/,(?=\s*[A-Za-z0-9_.\-]+=)/)){let o=r.trim();if(!o)continue;let s=o.split(";"),c=s[0].indexOf("=");if(c===-1)continue;let i=s[0].slice(0,c).trim(),l=s[0].slice(c+1).trim(),p=s.slice(1).map(f=>f.trim()).filter(Boolean).join(" \xB7 ")||void 0;i&&t.push({name:i,value:Tt(l),attributes:p});}return t}var L=class L{constructor(t,n,r){this.originals=new Map;this.apiCallWriter=null;this.statusMix={"2xx":0,"3xx":0,"4xx":0,"5xx":0,error:0};this.callCounter=0;this.apiCallCount=0;this.disposed=false;this._lastCallId=null;this.primitiveCallIds=new Map;this.context=t,this.assertionTracker=n??null,this.apiConfig=r??L.DEFAULT_API_CONFIG;try{this.apiCallWriter=new N("api-calls");}catch{}}get lastCallId(){return this._lastCallId}getCallIdForValue(t){return t!=null&&typeof t=="object"?D.get(t)??null:this.primitiveCallIds.get(t)??null}intercept(){for(let n of se){let r=this.context[n].bind(this.context);this.originals.set(n,r),this.context[n]=this.createWrapper(n,r);}let t=this.context.dispose.bind(this.context);this.originals.set("dispose",t),this.context.dispose=async n=>(this.disposed=true,t(n));}tallyStatus(t){if(t===null||t<=0){this.statusMix.error++;return}if(t>=500){this.statusMix["5xx"]++;return}if(t>=400){this.statusMix["4xx"]++;return}if(t>=300){this.statusMix["3xx"]++;return}if(t>=200){this.statusMix["2xx"]++;return}this.statusMix.error++;}getFileData(){return this.apiCallWriter?.close(),{apiCallsFile:this.apiCallWriter?.getCount()?this.apiCallWriter.getPath():null,apiCallsCount:this.apiCallWriter?.getCount()??0,apiStatusMix:{...this.statusMix}}}flushLegacyAnnotations(t){}dispose(){for(let[t,n]of this.originals)this.context[t]=n;this.originals.clear(),this.apiCallWriter?.close(),this.callCounter=0,this.apiCallCount=0,this._lastCallId=null,this.primitiveCallIds.clear();}get isDisposed(){return this.disposed}getCapturedCallCount(){return this.apiCallCount}tagResponseMethods(t,n){let r=this,o=t.headers.bind(t);t.headers=function(){let d=o();return D.set(d,n),d};let s=t.headersArray.bind(t);t.headersArray=function(){let d=s();return D.set(d,n),d};let c=t.json.bind(t);t.json=async function(){let d=await c();return d!=null&&typeof d=="object"&&D.set(d,n),d};let i=t.status.bind(t);t.status=function(){let d=i();return r.primitiveCallIds.set(d,n),d};let l=t.statusText.bind(t);t.statusText=function(){let d=l();return r.primitiveCallIds.set(d,n),d};let p=t.ok.bind(t);t.ok=function(){let d=p();return r.primitiveCallIds.set(d,n),d};let f=t.text.bind(t);t.text=async function(){let d=await f();return r.primitiveCallIds.set(d,n),d};let u=t.body.bind(t);t.body=async function(){let d=await u();return D.set(d,n),d};}createWrapper(t,n){let r=this;return async function(s,c){if(!Rt(s,r.apiConfig.apiIncludeUrls,r.apiConfig.apiExcludeUrls))return n(s,c);let i=`api-call-${r.callCounter++}`,l=new Date().toISOString(),p=t==="fetch"?(c?.method??"GET").toUpperCase():t.toUpperCase(),f=ue(c),u=performance.now();r._lastCallId=i,r.assertionTracker&&r.assertionTracker.setCurrentCallId(i);let a;try{a=await n(s,c);}catch(d){let g=performance.now();try{let h=r.apiConfig.captureRequestBody?I(f,r.apiConfig.redactBodyFields):null,w={id:i,timestamp:l,method:p,url:$(s),requestHeaders:null,requestBody:h,responseStatusCode:null,responseStatusText:null,responseHeaders:null,responseBody:null,responseTimeMs:Math.round((g-u)*100)/100,isBinary:!1,error:d instanceof Error?d.message:String(d)};r.apiCallWriter&&(r.apiCallWriter.append(w),r.apiCallCount++,r.tallyStatus(null));}catch{}throw d}try{let d=performance.now(),g=a.headers(),h=g["content-type"]??null,w=h?!ae(h):!1,k=null;r.apiConfig.captureRequestHeaders&&c?.headers&&(k=c.headers);let x=null;r.apiConfig.captureResponseHeaders&&(x=g);let R=r.apiConfig.captureRequestBody?f:null,A=null;if(r.apiConfig.captureResponseBody)try{w?A=(await a.body()).toString("base64"):A=await a.text();}catch{}let v=[],P=[];try{if(r.apiConfig.captureRequestHeaders&&(v=ce(c?.headers)),r.apiConfig.captureResponseHeaders){let m=a.headersArray().filter(b=>b.name.toLowerCase()==="set-cookie").map(b=>b.value);P=le(m);}}catch{}k=G(k,r.apiConfig.redactHeaders),x=G(x,r.apiConfig.redactHeaders),R=I(R,r.apiConfig.redactBodyFields),A=I(A,r.apiConfig.redactBodyFields);let y={id:i,timestamp:l,method:p,url:$(a.url()),requestHeaders:k,requestBody:R,responseStatusCode:a.status(),responseStatusText:a.statusText(),responseHeaders:x,responseBody:A,requestCookies:v.length?v:null,responseCookies:P.length?P:null,responseTimeMs:Math.round((d-u)*100)/100,isBinary:w,error:null};r.apiCallWriter&&(r.apiCallWriter.append(y),r.apiCallCount++,r.tallyStatus(y.responseStatusCode));}catch{}try{a[U]=i,r.tagResponseMethods(a,i);}catch{}return a}}};L.DEFAULT_API_CONFIG=Object.freeze({trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]});var O=L;Buffer.from([137,80,78,71,13,10,26,10]);var de=/Expected an image (\d+)px by (\d+)px, received (\d+)px by (\d+)px/;function Y(e){return e?de.test(e):false}function St(e){let{styleProps:t,defaults:n,inherited:r,maxNodes:o,maxText:s,maskBoxes:c,viewportBox:i,fullPage:l}=e,p={};for(let y=0;y<r.length;y++)p[r[y]]=true;let f=window.scrollX||window.pageXOffset||0,u=window.scrollY||window.pageYOffset||0,a=[],d=0,g=[];for(let y=0;y<c.length;y++){let m=c[y];g.push([m[0]+f,m[1]+u,m[2],m[3]]);}function h(y,m,b,S){for(let C=0;C<g.length;C++){let T=g[C];if(y<T[0]+T[2]&&y+b>T[0]&&m<T[1]+T[3]&&m+S>T[1])return true}return false}function w(y){let m=y.parentElement;if(!m)return 0;let b=m.children,S=0;for(let C=0;C<b.length;C++){let T=b[C];if(T===y)break;T.tagName===y.tagName&&S++;}return S}function k(y){let m="",b=y.childNodes;for(let S=0;S<b.length;S++){let C=b[S];C.nodeType===3&&(m+=C.nodeValue??"");}return m=m.replace(/\s+/g," ").trim(),m.length>s?m.slice(0,s):m}function x(y,m){let b;for(let S=0;S<t.length;S++){let C=t[S],T=y.getPropertyValue(C);if(T){if(p[C]){if(m&&m.getPropertyValue(C)===T)continue}else if(n[C]===T)continue;b||(b={}),b[C]=T;}}return b}let R=[{el:document.body,parentPath:"",parentComputed:null}];for(;R.length>0;){let y=R.pop(),m=y.el,b=window.getComputedStyle(m);if(b.display==="none")continue;let S=m.tagName.toLowerCase(),C=m.id?"#"+m.id:y.parentPath?y.parentPath+">"+S+"["+w(m)+"]":S,T=m.children;for(let H=T.length-1;H>=0;H--)R.push({el:T[H],parentPath:C,parentComputed:b});if(b.visibility==="hidden")continue;let _=m.getBoundingClientRect();if(_.width<=0||_.height<=0)continue;if(a.length>=o){d++;continue}let rt=Math.round(_.left+f),ot=Math.round(_.top+u),st=Math.round(_.width),it=Math.round(_.height),M={p:C,t:S,r:[rt,ot,st,it]};m.id&&(M.i=m.id);let at=m.getAttribute("class");at&&(M.c=at.replace(/\s+/g," ").trim());let ut=k(m);ut&&(M.x=ut);let ct=x(b,y.parentComputed);ct&&(M.s=ct),h(rt,ot,st,it)&&(M.m=1),a.push(M);}let A=Math.max(document.documentElement.scrollWidth,window.innerWidth),v=Math.max(document.documentElement.scrollHeight,window.innerHeight),P;return i?P=[Math.round(i[0]+f),Math.round(i[1]+u),Math.round(i[2]),Math.round(i[3])]:l?P=[0,0,A,v]:P=[Math.round(f),Math.round(u),window.innerWidth,window.innerHeight],{version:"1.0",url:location.href,viewport:{width:window.innerWidth,height:window.innerHeight},content:{width:A,height:v},captureBox:P,nodes:a,truncatedNodes:d}}var ye=["display","position","color","background-color","background-image","border-top-width","border-right-width","border-bottom-width","border-left-width","border-color","border-style","border-radius","box-shadow","opacity","transform","margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left","font-family","font-size","font-weight","line-height","letter-spacing","text-align","text-decoration-line","text-transform","flex-direction","justify-content","align-items","gap","z-index","overflow"],we={position:"static","background-color":"rgba(0, 0, 0, 0)","background-image":"none","border-top-width":"0px","border-right-width":"0px","border-bottom-width":"0px","border-left-width":"0px","border-style":"none","border-radius":"0px","box-shadow":"none",opacity:"1",transform:"none","margin-top":"0px","margin-right":"0px","margin-bottom":"0px","margin-left":"0px","padding-top":"0px","padding-right":"0px","padding-bottom":"0px","padding-left":"0px","text-decoration-line":"none","flex-direction":"row","justify-content":"normal","align-items":"normal",gap:"normal","z-index":"auto",overflow:"visible"},ke=["color","font-family","font-size","font-weight","line-height","letter-spacing","text-align","text-transform"],be=1024*1024,xe=1500,Ce=200;async function Re(e){let t=[];for(let n of e)try{let r=await n.boundingBox();r&&t.push([r.x,r.y,r.width,r.height]);}catch{}return t}async function At(e){let t=e.config??{};try{let n=e.maskLocators?.length?await Re(e.maskLocators):[],r=null;if(e.bounded){let s=await e.bounded.boundingBox();s&&(r=[s.x,s.y,s.width,s.height]);}let o={styleProps:ye,defaults:we,inherited:ke,maxNodes:t.maxNodes??xe,maxText:t.maxText??Ce,maskBoxes:n,viewportBox:r,fullPage:e.fullPage===!0};return await e.target.evaluate(St,o)}catch{return null}}function vt(e,t=be){let n=JSON.stringify(e);if(Buffer.byteLength(n,"utf-8")<=t)return {json:n,truncatedBytes:false};let r=e.nodes.slice(),o=0;for(;r.length>0&&Buffer.byteLength(n,"utf-8")>t;){let s=Math.max(1,Math.floor(r.length*.1));r.splice(-s,s),o+=s,n=JSON.stringify({...e,nodes:r,truncatedNodes:e.truncatedNodes+o});}return {json:n,truncatedBytes:true}}function Pt(e){return e.replace(/\.[A-Za-z0-9]+$/,"")+".dom.json"}function Nt(e){try{if(!existsSync(e))return null;let t=JSON.parse(readFileSync(e,"utf-8"));return Te(t)?t:null}catch{return null}}function Dt(e,t){try{return mkdirSync(dirname(e),{recursive:!0}),writeFileSync(e,t,"utf-8"),!0}catch{return false}}function Te(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.version=="string"&&Array.isArray(t.nodes)&&Array.isArray(t.captureBox)&&t.captureBox.length===4}var Se=new Set(["moved","resized"]);function q(e){return e.some(t=>!Se.has(t))}function K(e){let t=e.t;if(e.i&&(t+="#"+e.i),e.c){let n=e.c.split(" ").filter(Boolean).slice(0,3);n.length>0&&(t+="."+n.join("."));}return t}function Ae(e,t){let n=[],r=Math.abs(e.r[0]-t.r[0]),o=Math.abs(e.r[1]-t.r[1]),s=Math.abs(e.r[2]-t.r[2]),c=Math.abs(e.r[3]-t.r[3]);return (r>1||o>1)&&n.push("moved"),(s>1||c>1)&&n.push("resized"),n}function ve(e,t){let n=e.s??{},r=t.s??{},o=new Set([...Object.keys(n),...Object.keys(r)]),s=[];for(let c of o){let i=n[c],l=r[c];i!==l&&s.push({prop:c,from:i??"(initial)",to:l??"(initial)"});}return s.sort((c,i)=>c.prop.localeCompare(i.prop)),s}function _t(e){return e.i?"i:"+e.t+"#"+e.i:e.c?"c:"+e.t+"."+e.c:null}function Pe(e,t){let n=new Map;for(let u of e)n.set(u.p,u);let r=[],o=[],s=new Set;for(let u of t){let a=n.get(u.p);if(a&&a.t!==u.t){o.push(u);continue}a&&!s.has(a)?(s.add(a),r.push({before:a,after:u})):o.push(u);}let c=e.filter(u=>!s.has(u)),i=new Map;for(let u of c){let a=_t(u);if(!a)continue;let d=i.get(a);d?d.push(u):i.set(a,[u]);}let l=[],p=new Set;for(let u of o){let a=_t(u),g=(a?i.get(a):void 0)?.find(h=>!p.has(h));g?(p.add(g),r.push({before:g,after:u})):l.push(u);}let f=c.filter(u=>!p.has(u));return {pairs:r,removed:f,added:l}}function Ne(e,t){let n=[];return (e.i??"")!==(t.i??"")&&n.push({prop:"id",from:e.i??"(none)",to:t.i??"(none)"}),(e.c??"")!==(t.c??"")&&n.push({prop:"class",from:e.c??"(none)",to:t.c??"(none)"}),n}function Z(e,t){let n=(t[2]??0)*(t[3]??0);return n<=0?0:Math.min(1,e.r[2]*e.r[3]/n)}function Mt(e,t,n={}){let r=n.maxChanges??50,o=n.includeText!==false,s=n.includeStyles!==false,c=e.nodes.filter(g=>g.m!==1),i=t.nodes.filter(g=>g.m!==1),{pairs:l,removed:p,added:f}=Pe(c,i),u=[];for(let{before:g,after:h}of l){let w=Ae(g,h),k=s?ve(g,h):[];k.length>0&&w.push("restyled");let x=Ne(g,h);x.length>0&&w.push("attrs");let R=o&&(g.x??"")!==(h.x??"");if(R&&w.push("text"),w.length===0)continue;let A=Z(h,t.captureBox);u.push({score:A,change:{path:h.p,label:K(h),kinds:w,rect:h.r,baselineRect:g.r,areaPct:A,...x.length>0?{attrs:x}:{},...k.length>0?{styles:k}:{},...R?{text:{from:g.x??"",to:h.x??""}}:{}}});}for(let g of f){let h=Z(g,t.captureBox);u.push({score:h,change:{path:g.p,label:K(g),kinds:["added"],rect:g.r,areaPct:h}});}for(let g of p){let h=Z(g,e.captureBox);u.push({score:h,change:{path:g.p,label:K(g),kinds:["removed"],baselineRect:g.r,areaPct:h}});}let a=u.filter(g=>q(g.change.kinds)).length;return u.sort((g,h)=>{if(a>0){let w=q(g.change.kinds)?1:0,k=q(h.change.kinds)?1:0;if(w!==k)return k-w}return h.score-g.score}),{changes:u.slice(0,r).map((g,h)=>({rank:h+1,...g.change,...a>0&&!q(g.change.kinds)?{consequence:true}:{}})),total:u.length,rootCauses:a}}var Bt="__testrelic_snapshot_path_probe__.png",Et=Symbol.for("testrelic.snapshotPathWarned");function De(){let e=globalThis,t=e[Et];return t||(t={warned:false},e[Et]=t),t}function F(e){try{let t=e.snapshotPath(Bt,{kind:"screenshot"});return typeof t=="string"&&t.endsWith(Bt)}catch{return false}}function j(e){let t=De();t.warned||(t.warned=true,process.stderr.write(`[testrelic] ${e} needs Playwright >= 1.51 for testInfo.snapshotPath(name, { kind }); this project's Playwright resolves that call the older way. Everything else in the reporter is unaffected \u2014 upgrade Playwright to enable it.
6
+ `));}var It="testrelic-visual-dom",Ie=new Set(["toHaveScreenshot","toMatchVisualBaseline"]);function Ot(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.boundingBox=="function"&&typeof t.page=="function"}function Oe(e){if(typeof e!="object"||e===null)return false;let t=e;return typeof t.evaluate=="function"&&typeof t.screenshot=="function"}function Le(e){let t=e[0];if(typeof t=="string")return t;if(Array.isArray(t))return t.join("/");if(typeof t=="object"&&t!==null){let n=t.name;if(typeof n=="string")return n}return null}function qe(e){for(let t of e)if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t;return {}}function Fe(e){let t=e.mask;return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null&&typeof n.boundingBox=="function"):[]}function je(e){return /\.(png|jpg|jpeg)$/i.test(e)?e:`${e}.png`}var He=/^(.+)-(expected|actual|diff|previous)\.[A-Za-z0-9]+$/;function We(e,t,n){let r=e.attachments;for(let o=t;o<r.length;o++){let s=He.exec(r[o]?.name??"");if(s)return s[1]}return n}async function Ve(e){let t=qe(e.args),n=Ot(e.received)?e.received:null,r=n?n.page():e.received;return At({target:r,bounded:n,maskLocators:Fe(t),fullPage:t.fullPage===true})}function Ue(e){let t=e.config?.updateSnapshots;return t==="all"||t==="changed"}async function ze(e,t){let n=Le(e.args);if(!n)return;if(!F(e.testInfo)){j("DOM comparison");return}let r=e.testInfo.snapshotPath(je(n),{kind:"screenshot"}),o=Pt(r),s=We(e.testInfo,e.attachedBefore,basename(r,extname(r))),c=vt(t),l=Ue(e.testInfo)?null:Nt(o);if(!l){Dt(o,c.json);return}let{changes:p,total:f,rootCauses:u}=Mt(l,t),a;try{a=e.testInfo.outputPath(`${s}.actual.dom.json`),writeFileSync(a,c.json,"utf-8");}catch{a=void 0;}let d={stem:s,changes:p,total:f,rootCauses:u,truncated:c.truncatedBytes||t.truncatedNodes>0,captureBox:t.captureBox,...existsSync(o)?{baselineDomPath:o}:{},...a?{actualDomPath:a}:{}};await e.testInfo.attach(It,{body:Buffer.from(JSON.stringify([d])),contentType:"application/json"});}function Lt(e,t){let n=function(c,...i){let l=e(c,...i);return !(Ot(c)||Oe(c))||typeof l!="object"||l===null?l:new Proxy(l,{get(f,u,a){let d=Reflect.get(f,u,a);if(typeof u!="string"||!Ie.has(u)||typeof d!="function")return d;let g=d;return async function(...w){let k=t(),x=null,R=k?.attachments.length??0;if(k)try{x=await Ve({received:c,args:w,testInfo:k,attachedBefore:R});}catch{}try{return await g.apply(f,w)}finally{if(k&&x)try{await ze({received:c,args:w,testInfo:k,attachedBefore:R},x);}catch{}}}}})},r=e,o=n;for(let s of Object.keys(r))o[s]=r[s];return n}var qt="testrelic-visual";var Ye=[".png",".jpg",".jpeg"];function Ke(e){let t=e.toLowerCase();return Ye.some(n=>t.endsWith(n))?e:`${e}.png`}function Ze(){try{return test.info()}catch{return null}}function Qe(e,t){for(let n=t;n<e.length;n++){let r=/^(.+)-(expected|actual|diff|previous)\.[A-Za-z0-9]+$/.exec(e[n]?.name??"");if(r)return r[1]}return null}async function tn(e,t){if(!F(e))return j("Attaching the baseline of a passing comparison"),null;try{let n=e.snapshotPath(t,{kind:"screenshot"}),r=extname(n)||".png",o=basename(n,r);return await e.attach(`${o}-expected${r}`,{path:n}),o}catch{return null}}async function en(e,t){try{await e.attach(qt,{body:Buffer.from(JSON.stringify([t])),contentType:"application/json"});}catch{}}async function Q(e,t,n={}){let r={...n};delete r.tags;let o=Ke(t),s=Ze(),c=s?.attachments.length??0,i=true,l="";try{await expect(e).toHaveScreenshot(o,r);}catch(p){i=false,l=p instanceof Error?p.message:String(p);}if(s){let p=i?await tn(s,o):Qe(s.attachments,c);if(p){let f=!i&&!Y(l)&&!s.attachments.some((u,a)=>a>=c&&u.name.startsWith(`${p}-diff.`));await en(s,{stem:p,name:t,status:i?"passed":f?"new":"failed"});}}return {pass:i,name:"toMatchVisualBaseline",message:()=>i?`Expected "${t}" to differ from its visual baseline, but it matched.`:l}}expect.extend({toMatchVisualBaseline:Q});function on(){try{return test.info()}catch{return null}}var yr=Lt(kt(expect),on),sn="__testrelic_api_config",an="__testrelic_config_trackApiCalls";function un(e){let t=e.annotations.find(r=>r.type===sn&&r.description!==void 0);if(t)try{return JSON.parse(t.description,cn)}catch{}let n=e.annotations.find(r=>r.type===an&&r.description!==void 0);return n?{trackApiCalls:n.description!=="false",captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}:{trackApiCalls:true,captureRequestHeaders:true,captureResponseHeaders:true,captureRequestBody:true,captureResponseBody:true,captureAssertions:true,redactHeaders:["authorization","cookie","set-cookie","x-api-key"],redactBodyFields:["password","secret","token","apiKey","api_key"],apiIncludeUrls:[],apiExcludeUrls:[]}}function cn(e,t){if(typeof t=="object"&&t!==null&&t.__regexp===true&&typeof t.source=="string"){let{source:n,flags:r}=t;return new RegExp(n,r)}return t}var ln={page:async({page:e},t,n)=>{let r=new B(e);try{await r.init();}catch{}await t(e);try{let{navigations:o,networkRequestsFile:s,networkRequestsCount:c,consoleLogsFile:i,consoleLogsCount:l}=await r.getFileData(),p={testRelicData:!0,version:PAYLOAD_VERSION,navigations:o,apiAssertions:[],networkRequestsFile:s,networkRequestsCount:c,consoleLogsFile:i,consoleLogsCount:l,apiCallsFile:null,apiCallsCount:0};await n.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(p)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}r.dispose();},request:async({request:e},t,n)=>{let r=un(n);if(!r.trackApiCalls){await t(e);return}let o=new E,s=new O(e,o,r);s.intercept(),z(o,s);try{await t(e);}finally{z(null,null);}try{let{apiCallsFile:c,apiCallsCount:i,apiStatusMix:l}=s.getFileData(),p=r.captureAssertions?o.getData():[],f={testRelicData:!0,version:PAYLOAD_VERSION,navigations:[],apiAssertions:p,networkRequestsFile:null,networkRequestsCount:0,consoleLogsFile:null,consoleLogsCount:0,apiCallsFile:c,apiCallsCount:i,apiStatusMix:l};await n.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(f)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}s.dispose(),o.dispose();}};async function wr(e,t){let n=new B(e);try{await n.init();}catch{}return async()=>{try{let{navigations:r,networkRequestsFile:o,networkRequestsCount:s,consoleLogsFile:c,consoleLogsCount:i}=await n.getFileData(),l={testRelicData:!0,version:PAYLOAD_VERSION,navigations:r,apiAssertions:[],networkRequestsFile:o,networkRequestsCount:s,consoleLogsFile:c,consoleLogsCount:i,apiCallsFile:null,apiCallsCount:0};await t.attach(ATTACHMENT_NAME,{body:Buffer.from(JSON.stringify(l)),contentType:ATTACHMENT_CONTENT_TYPE});}catch{}n.dispose();}}var kr=test.extend(ln);export{yr as expect,un as readApiConfig,kr as test,ln as testRelicFixture,wr as trackPage};//# sourceMappingURL=fixture.js.map
5
7
  //# sourceMappingURL=fixture.js.map