Skip to content

Commit

Permalink
test: move async predicate to waitForResponse describe (#8285)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok committed Apr 28, 2022
1 parent 15583c3 commit 25d363b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/page.spec.ts
Expand Up @@ -763,21 +763,6 @@ describe('Page', function () {
.catch((error_) => (error = error_));
expect(error).toBeInstanceOf(puppeteer.errors.TimeoutError);
});
it('should work with async predicate', async () => {
const { page, server } = getTestState();
await page.goto(server.EMPTY_PAGE);
const [response] = await Promise.all([
page.waitForResponse(async (response) => {
return response.url() === server.PREFIX + '/digits/2.png';
}),
page.evaluate(() => {
fetch('/digits/1.png');
fetch('/digits/2.png');
fetch('/digits/3.png');
}),
]);
expect(response.url()).toBe(server.PREFIX + '/digits/2.png');
});
it('should work with no timeout', async () => {
const { page, server } = getTestState();

Expand Down Expand Up @@ -846,6 +831,21 @@ describe('Page', function () {
]);
expect(response.url()).toBe(server.PREFIX + '/digits/2.png');
});
it('should work with async predicate', async () => {
const { page, server } = getTestState();
await page.goto(server.EMPTY_PAGE);
const [response] = await Promise.all([
page.waitForResponse(async (response) => {
return response.url() === server.PREFIX + '/digits/2.png';
}),
page.evaluate(() => {
fetch('/digits/1.png');
fetch('/digits/2.png');
fetch('/digits/3.png');
}),
]);
expect(response.url()).toBe(server.PREFIX + '/digits/2.png');
});
it('should work with no timeout', async () => {
const { page, server } = getTestState();

Expand Down

0 comments on commit 25d363b

Please sign in to comment.