MCPcopy
hub / github.com/vercel/next.js / beforePageLoad

Function beforePageLoad

test/e2e/app-dir/actions/app-action.test.ts:148–161  ·  view source on GitHub ↗
(page)

Source from the content-addressed store, hash-verified

146 const customErrorText = 'Custom error!'
147 const browser = await next.browser('/error-handling', {
148 beforePageLoad(page) {
149 page.route('**/error-handling', async (route) => {
150 const requestHeaders = await route.request().allHeaders()
151 if (requestHeaders['next-action']) {
152 await route.fulfill({
153 status: 500,
154 contentType: 'text/plain',
155 body: customErrorText,
156 })
157 } else {
158 await route.continue()
159 }
160 })
161 },
162 })
163
164 await browser.elementById('submit-transition').click()

Callers

nothing calls this directly

Calls 11

routeMethod · 0.80
includesMethod · 0.80
urlMethod · 0.65
pushMethod · 0.65
requestMethod · 0.45
stringifyMethod · 0.45
onMethod · 0.45
methodMethod · 0.45
abortMethod · 0.45
catchMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected