mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: move async predicate to waitForResponse describe (#8285)
This commit is contained in:
parent
15583c3eac
commit
25d363bf9c
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user