test: remove some flakiness (#12346)

This commit is contained in:
Nikolay Vitkov 2024-04-26 10:58:02 +02:00 committed by GitHub
parent fedd8a9628
commit 137236ee2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 24 deletions

View File

@ -911,13 +911,8 @@ describe('network', function () {
it('should work for document type', async () => {
const {page, server} = await getTestState();
const requests: HTTPRequest[] = [];
page.on('request', request => {
return requests.push(request);
});
await page.goto(server.EMPTY_PAGE);
expect(requests).toHaveLength(1);
const request = requests[0]!;
const response = await page.goto(server.EMPTY_PAGE);
const request = response!.request();
expect(request.resourceType()).toBe('document');
});
@ -942,13 +937,7 @@ describe('network', function () {
it('should work', async () => {
const {page, server} = await getTestState();
const responses: HTTPResponse[] = [];
page.on('response', response => {
return responses.push(response);
});
await page.goto(server.EMPTY_PAGE);
expect(responses).toHaveLength(1);
const response = responses[0]!;
const response = (await page.goto(server.EMPTY_PAGE))!;
const remoteAddress = response.remoteAddress();
// Either IPv6 or IPv4, depending on environment.
expect(

View File

@ -1008,14 +1008,11 @@ describe('cooperative request interception', function () {
const {page, server} = await getTestState();
await page.setRequestInterception(true);
const requests: HTTPRequest[] = [];
page.on('request', request => {
requests.push(request);
void request.continue({}, 0);
});
await page.goto(server.EMPTY_PAGE);
expect(requests).toHaveLength(1);
const request = requests[0]!;
const response = await page.goto(server.EMPTY_PAGE);
const request = response!.request();
expect(request.resourceType()).toBe('document');
});

View File

@ -937,14 +937,11 @@ describe('request interception', function () {
const {page, server} = await getTestState();
await page.setRequestInterception(true);
const requests: HTTPRequest[] = [];
page.on('request', request => {
requests.push(request);
void request.continue();
});
await page.goto(server.EMPTY_PAGE);
expect(requests).toHaveLength(1);
const request = requests[0]!;
const response = await page.goto(server.EMPTY_PAGE);
const request = response!.request();
expect(request.resourceType()).toBe('document');
});