Skip to content

Commit

Permalink
fix(testing): re-add Puppeteer asElement() calls
Browse files Browse the repository at this point in the history
Fixes a regression caused by the removal of a few `asElement()` calls. Turns out these are necessary for the case where the handle is `null`. To avoid type errors, we cast the returned value to be of type `ElementHandle<Element>` rather than `ElementHandle<Node`.

STENCIL-1032: `E2EPage.find()` throws error when using piercing selector targeting a non-existing element

Fixes: #5113
  • Loading branch information
tanner-reits committed Nov 30, 2023
1 parent 33f5158 commit 17ee608
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/testing/puppeteer/puppeteer-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ async function findWithCssSelector(
return null;
}

elmHandle = shadowHandle;
elmHandle = shadowHandle.asElement() as puppeteer.ElementHandle<Element>;
}

return elmHandle;
Expand Down Expand Up @@ -646,7 +646,7 @@ async function findWithText(
);

if (jsHandle) {
return jsHandle;
return jsHandle.asElement() as puppeteer.ElementHandle<Element>;
}

return null;
Expand Down

0 comments on commit 17ee608

Please sign in to comment.