Skip to content

Commit

Permalink
Add comment explaining unusual return behavior of page.evaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewortwein committed Nov 25, 2024
1 parent e2dd287 commit 1d6eff2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/playwright/src/takeSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 1d6eff2

Please sign in to comment.