Skip to content

Commit

Permalink
fix: history-api-fallback.test.js test
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdikhashan committed Aug 3, 2024
1 parent fee0ba7 commit ef3f14c
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions test/e2e/history-api-fallback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,42 +615,48 @@ test.describe("historyApiFallback option", () => {
expect(pageErrors).toMatchSnapshotWithArray("page errors");
});

test("should perform HEAD request in same way as GET", async ({ page }) => {
await page.goto(`http://127.0.0.1:${port}/foo`, {
waitUntil: "networkidle0",
});
test(
"should perform HEAD request in same way as GET",
async ({ page }) => {
await page.goto(`http://127.0.0.1:${port}/foo`, {
waitUntil: "networkidle0",
});

const responseGet = await page.evaluate(async () => {
const response = await fetch("/foo", { method: "GET" });
const responseGet = await page.evaluate(async () => {
const response = await fetch("/foo", { method: "GET" });

return {
contentType: response.headers.get("content-type"),
statusText: response.statusText,
text: await response.text(),
};
});
return {
contentType: response.headers.get("content-type"),
statusText: response.statusText,
text: await response.text(),
};
});

expect(responseGet.contentType).toMatchSnapshotWithArray("content type");
expect(responseGet.contentType).toMatchSnapshotWithArray(
"content type",
);

expect(responseGet.statusText).toMatchSnapshotWithArray("status text");
expect(responseGet.statusText).toMatchSnapshotWithArray("status text");

expect(responseGet.text).toMatchSnapshotWithArray("text");
expect(responseGet.text).toMatchSnapshotWithArray("text");

const responseHead = await page.evaluate(async () => {
const response = await fetch("/foo", { method: "HEAD" });
const responseHead = await page.evaluate(async () => {
const response = await fetch("/foo", { method: "HEAD" });

return {
contentType: response.headers.get("content-type"),
statusText: response.statusText,
text: await response.text(),
};
});
return {
contentType: response.headers.get("content-type"),
statusText: response.statusText,
text: await response.text(),
};
});

expect(responseHead).toMatchObject({
...responseGet,
// HEAD response has an empty body
text: "",
});
});
expect(responseHead).toMatchObject({
...responseGet,
// HEAD response has an empty body
text: "",
});
},
{ timeout: 90 * 1000 },
);
});
});

0 comments on commit ef3f14c

Please sign in to comment.