diff --git a/src/csf/__snapshots__/transformCsf.test.ts.snap b/src/csf/__snapshots__/transformCsf.test.ts.snap index a51ae2f..7fff882 100644 --- a/src/csf/__snapshots__/transformCsf.test.ts.snap +++ b/src/csf/__snapshots__/transformCsf.test.ts.snap @@ -41,10 +41,12 @@ if (!require.main) { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -121,10 +123,12 @@ if (!require.main) { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -187,10 +191,12 @@ if (!require.main) { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } diff --git a/src/playwright/transformPlaywright.test.ts b/src/playwright/transformPlaywright.test.ts index 37ac1ad..0900664 100644 --- a/src/playwright/transformPlaywright.test.ts +++ b/src/playwright/transformPlaywright.test.ts @@ -82,10 +82,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -140,10 +142,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -216,10 +220,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -292,10 +298,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -350,10 +358,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -439,10 +449,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -497,10 +509,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -555,10 +569,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -613,10 +629,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -695,10 +713,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -753,10 +773,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -831,10 +853,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -921,10 +945,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -995,10 +1021,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -1069,10 +1097,12 @@ describe('Playwright', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } diff --git a/src/playwright/transformPlaywright.ts b/src/playwright/transformPlaywright.ts index ecd4f02..818296c 100644 --- a/src/playwright/transformPlaywright.ts +++ b/src/playwright/transformPlaywright.ts @@ -35,7 +35,9 @@ export const testPrefixer: TestPrefixer = (context) => { // Retry the test, possible Vite dep optimization flake throw err; } else { - await globalThis.__sbPostVisit(page, {...context, hasFailure: true }); + if(globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, {...context, hasFailure: true }); + } throw err; } } diff --git a/src/playwright/transformPlaywrightJson.test.ts b/src/playwright/transformPlaywrightJson.test.ts index 1be7b85..0a1b398 100644 --- a/src/playwright/transformPlaywrightJson.test.ts +++ b/src/playwright/transformPlaywrightJson.test.ts @@ -67,10 +67,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -125,10 +127,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -185,10 +189,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -292,10 +298,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -352,10 +360,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -435,10 +445,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -539,10 +551,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -597,10 +611,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -657,10 +673,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -749,10 +767,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } } @@ -832,10 +852,12 @@ describe('Playwright Json', () => { if (err.toString().includes('Execution context was destroyed')) { throw err; } else { - await globalThis.__sbPostVisit(page, { - ...context, - hasFailure: true - }); + if (globalThis.__sbPostVisit) { + await globalThis.__sbPostVisit(page, { + ...context, + hasFailure: true + }); + } throw err; } }