fix: page.goto error throwing on 40x/50x responses with an empty body (#9523) (#9577)

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
This commit is contained in:
Rafael Martins
2023-02-06 06:40:51 -03:00
committed by GitHub
parent 9b11b6a4e0
commit ddb0cc174d
2 changed files with 27 additions and 0 deletions

View File

@@ -304,6 +304,30 @@ describe('navigation', function () {
expect(response.ok()).toBe(false);
expect(response.status()).toBe(404);
});
it('should not throw an error for a 404 response with an empty body', async () => {
const {page, server} = getTestState();
server.setRoute('/404-error', (_, res) => {
res.statusCode = 404;
res.end();
});
const response = (await page.goto(server.PREFIX + '/404-error'))!;
expect(response.ok()).toBe(false);
expect(response.status()).toBe(404);
});
it('should not throw an error for a 500 response with an empty body', async () => {
const {page, server} = getTestState();
server.setRoute('/500-error', (_, res) => {
res.statusCode = 500;
res.end();
});
const response = (await page.goto(server.PREFIX + '/500-error'))!;
expect(response.ok()).toBe(false);
expect(response.status()).toBe(500);
});
it('should return last response in redirect chain', async () => {
const {page, server} = getTestState();