Skip to content

Commit

Permalink
chore: avoid evaluates in screenshot on failure (#16386)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman committed Aug 9, 2022
1 parent fa9c20c commit 2efe947
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/playwright-test/src/index.ts
Expand Up @@ -330,7 +330,9 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
(page as any)[screenshottedSymbol] = true;
const screenshotPath = path.join(_artifactsDir(), createGuid() + '.png');
temporaryScreenshots.push(screenshotPath);
await page.screenshot({ timeout: 5000, path: screenshotPath }).catch(() => {});
// Pass caret=initial to avoid any evaluations that might slow down the screenshot
// and let the page modify itself from the problematic state it had at the moment of failure.
await page.screenshot({ timeout: 5000, path: screenshotPath, caret: 'initial' }).catch(() => {});
};

const screenshotOnTestFailure = async () => {
Expand Down Expand Up @@ -432,7 +434,9 @@ export const test = _baseTest.extend<TestFixtures, WorkerFixtures>({
await Promise.all(context.pages().map(async page => {
if ((page as any)[screenshottedSymbol])
return;
await page.screenshot({ timeout: 5000, path: addScreenshotAttachment() }).catch(() => {});
// Pass caret=initial to avoid any evaluations that might slow down the screenshot
// and let the page modify itself from the problematic state it had at the moment of failure.
await page.screenshot({ timeout: 5000, path: addScreenshotAttachment(), caret: 'initial' }).catch(() => {});
}));
}
}).concat(leftoverApiRequests.map(async context => {
Expand Down

0 comments on commit 2efe947

Please sign in to comment.