import { nextTestSetup } from 'e2e-utils'
describe('dynamic-href', () => {
const {
isNextDev: isDev,
next,
skipped,
} = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
if (isDev) {
it('should error when using dynamic href.pathname in app dir', async () => {
const browser = await next.browser('/object')
await expect(browser).toDisplayRedbox(`
{
"code": "E267",
"description": "Dynamic href \`/object/[slug]\` found in while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href",
"environmentLabel": null,
"label": "Runtime Error",
"source": "app/object/page.js (5:5) @ HomePage
> 5 | {
const browser = await next.browser('/string')
await expect(browser).toDisplayRedbox(`
{
"code": "E267",
"description": "Dynamic href \`/object/[slug]\` found in while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href",
"environmentLabel": null,
"label": "Runtime Error",
"source": "app/string/page.js (5:5) @ HomePage
> 5 |
| ^",
"stack": [
"HomePage app/string/page.js (5:5)",
],
}
`)
})
} else {
it('should not error on /object in prod', async () => {
const browser = await next.browser('/object')
expect(await browser.elementByCss('#link').text()).toBe('to slug')
})
it('should not error on /string in prod', async () => {
const browser = await next.browser('/string')
expect(await browser.elementByCss('#link').text()).toBe('to slug')
})
}
})