feat(types): add types for page.$$eval (#6139)

* feat(types): add types for `page.$$eval`

* Add new-docs for $$eval

* fix example

* linting
This commit is contained in:
Jack Franklin
2020-07-03 15:23:51 +01:00
committed by GitHub
parent f7857d27c4
commit 5049b83186
8 changed files with 120 additions and 47 deletions

View File

@@ -218,7 +218,7 @@ describe('querySelector', function () {
'<html><body><div class="tweet"><div class="like">100</div><div class="like">10</div></div></body></html>'
);
const tweet = await page.$('.tweet');
const content = await tweet.$$eval('.like', (nodes) =>
const content = await tweet.$$eval('.like', (nodes: HTMLElement[]) =>
nodes.map((n) => n.innerText)
);
expect(content).toEqual(['100', '10']);
@@ -231,7 +231,7 @@ describe('querySelector', function () {
'<div class="a">not-a-child-div</div><div id="myId"><div class="a">a1-child-div</div><div class="a">a2-child-div</div></div>';
await page.setContent(htmlContent);
const elementHandle = await page.$('#myId');
const content = await elementHandle.$$eval('.a', (nodes) =>
const content = await elementHandle.$$eval('.a', (nodes: HTMLElement[]) =>
nodes.map((n) => n.innerText)
);
expect(content).toEqual(['a1-child-div', 'a2-child-div']);