Unverified Commit 89d40df2 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack Build: Fix middleware rewrite test (#79697)

## What?

The reason this test fails seems to be that the `browser.on('request'`
gets registered too late and the requests are not tracked because of
that. Seems it can flake with webpack too. Switched to `beforePageLoad`
to register it always. That switch makes the test consistently pass with
Turbopack too.
parent 0bcbab52
......@@ -24,15 +24,19 @@ describe('Middleware Rewrite', () => {
function tests() {
it('should handle catch-all rewrite correctly', async () => {
const browser = await next.browser('/', { waitHydration: false })
let requests: string[] = []
if (!(global as any).isNextDev) {
let requests = []
browser.on('request', (req) => {
requests.push(new URL(req.url()).pathname)
})
const browser = await next.browser('/', {
waitHydration: false,
beforePageLoad(page) {
page.on('request', (request) => {
const url = new URL(request.url())
requests.push(url.pathname)
})
},
})
if (!(global as any).isNextDev) {
browser.elementByCss('#to-article-rewrite').moveTo()
await retry(async () => {
......
......@@ -7573,9 +7573,10 @@
"Middleware Rewrite should rewrite to the external url for incoming data request externally rewritten",
"Middleware Rewrite should rewrite when not using localhost",
"Middleware Rewrite should rewrite without hard navigation",
"Middleware Rewrite support colons in path"
"Middleware Rewrite support colons in path",
"Middleware Rewrite should handle catch-all rewrite correctly"
],
"failed": ["Middleware Rewrite should handle catch-all rewrite correctly"],
"failed": [],
"pending": [
"Middleware Rewrite includes the locale in rewrites by default"
],
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment