Files
next.js/test/e2e/app-dir/interception-routes-output-export/interception-routes-output-export.test.ts
Zack TannerandGitHub 808d2ba3e0 error when output: export is used with intercepting routes (#75058)
Intercepting routes are built on top of
[rewrites](https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites)
which is one of the listed [unsupported
features](https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features)
of `output: "export"`.

However, because the Next.js server injects the interception routes,
it's not caught by existing validation logic in the export flow.

This properly documents that intercepting routes are not currently
supported by `output: "export"` and hard errors in next dev/build if
detected. Previously route interception would just not have worked,
instead serving the non-intercepted page when built, leading to a
confusing experience.

We eventually want to support this with improved SPA/export features,
however that's out of scope for this PR: the goal here is to ensure
we're providing more immediate feedback about the fact that this is
unsupported.
2025-01-18 11:24:58 -08:00

31 lines
919 B
TypeScript

import { isNextDev, isNextStart } from 'e2e-utils'
import { findPort, killApp, launchApp, nextBuild, retry } from 'next-test-utils'
describe('interception-routes-output-export', () => {
it('should error when using interception routes with static export', async () => {
if (isNextStart) {
const { code, stderr } = await nextBuild(__dirname, [], { stderr: true })
expect(stderr).toContain(
'Intercepting routes are not supported with static export.'
)
expect(code).toBe(1)
} else if (isNextDev) {
let stderr = ''
const port = await findPort()
const app = await launchApp(__dirname, port, {
onStderr(msg) {
stderr += msg || ''
},
})
await retry(async () => {
expect(stderr).toContain(
'Intercepting routes are not supported with static export.'
)
})
await killApp(app)
}
})
})