/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
test/e2e/next-link-errors/next-link-errors.test.ts
66 строк
2 KB
Tim Neutkens
test: migrate webdriver callers to next.browser (#93941)
22 май 2026, 15:01
Не верифицирован
22 май 2026, 15:01
e860cec
Код
Авторство
О чём код?
import { nextTestSetup } from 'e2e-utils' describe('next-link', () => { const { skipped, next, isNextDev } = nextTestSetup({ files: __dirname, skipDeployment: true, }) if (skipped) return it('errors on invalid href', async () => { const browser = await next.browser('/invalid-href') if (isNextDev) { await expect(browser).toDisplayRedbox(` { "code": "E319", "description": "Failed prop type: The prop \`href\` expects a \`string\` or \`object\` in \`<Link>\`, but got \`undefined\` instead. Open your browser's console to view the Component stack trace.", "environmentLabel": null, "label": "Runtime Error", "source": "app/invalid-href/page.js (6:10) @ Hello > 6 | return <Link>Hello, Dave!</Link> | ^", "stack": [ "Hello app/invalid-href/page.js (6:10)", ], } `) } // Client errors show "This page couldn\u2019t load" expect(await browser.elementByCss('body').text()).toContain( 'This page couldn\u2019t load' ) }) it('invalid `prefetch` causes runtime error (dev-only)', async () => { const browser = await next.browser('/invalid-prefetch') if (isNextDev) { await expect(browser).toDisplayRedbox(` { "code": "E319", "description": "Failed prop type: The prop \`prefetch\` expects a \`boolean | "auto"\` in \`<Link>\`, but got \`string\` instead. Open your browser's console to view the Component stack trace.", "environmentLabel": null, "label": "Runtime Error", "source": "app/invalid-prefetch/page.js (7:5) @ Hello > 7 | <Link prefetch="unknown" href="https://nextjs.org/"> | ^", "stack": [ "Hello app/invalid-prefetch/page.js (7:5)", ], } `) // Client errors show "This page couldn\u2019t load" expect(await browser.elementByCss('body').text()).toContain( 'This page couldn\u2019t load' ) } else { expect(await browser.elementByCss('body').text()).toMatchInlineSnapshot( `"Link with unknown \`prefetch\` renders in prod."` ) } }) })