From 1d6eff2ea973173815a9ad9f5f3602a687d65226 Mon Sep 17 00:00:00 2001 From: Andrew Ortwein Date: Mon, 25 Nov 2024 18:16:38 -0500 Subject: [PATCH] Add comment explaining unusual return behavior of page.evaluate --- packages/playwright/src/takeSnapshot.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/playwright/src/takeSnapshot.ts b/packages/playwright/src/takeSnapshot.ts index 7beeaa7b..8ec08f04 100644 --- a/packages/playwright/src/takeSnapshot.ts +++ b/packages/playwright/src/takeSnapshot.ts @@ -35,6 +35,9 @@ async function takeSnapshot( // Serialize and capture the DOM const domSnapshot: elementNode = await page.evaluate(dedent` ${rrweb}; + // page.evaluate returns the value of the function being evaluated. In this case, it means that + // it is returning either the resolved value of the Promise or the return value of the call to + // the snapshot function. See https://playwright.dev/docs/api/class-page#page-evaluate. if (typeof define === "function" && define.amd) { // AMD support is detected, so we need to load rrwebSnapshot asynchronously new Promise((resolve) => {