Skip to content

Commit ba93b6d

Browse files
sommeeeervicb
authored andcommitted
fix test
1 parent d89bd75 commit ba93b6d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/e2e/app-router/e2e/middleware.rewrite.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ test("Middleware Rewrite External Image", async ({ page }) => {
3434
});
3535

3636
test("Middleware Rewrite Status Code", async ({ page }) => {
37+
// Need to set up the event before navigating to the page to avoid missing it
38+
// We need to check the URL here also cause there will be multiple responses (i.e the fonts, css, js, etc)
3739
page.on("response", async (response) => {
38-
// Need to set up the event before navigating to the page to avoid missing it
39-
// We need to check the URL here also cause there will be multiple responses (i.e the fonts, css, js, etc)
40-
if (response.url() === "/rewrite-status-code") {
40+
// `response.url()` will be the full URL including the host, so we need to check the pathname
41+
if (new URL(response.url()).pathname === "/rewrite-status-code") {
4142
expect(response.status()).toBe(403);
4243
}
4344
});

0 commit comments

Comments
 (0)