mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What? Deprecate undocumented custom-server methods exposed by `next()` while preserving their runtime behavior. - Add TypeScript deprecation annotations and one-time runtime warnings for `setAssetPrefix()`, logging helpers, `revalidate()`, and legacy `render*` helpers. - Extend custom-server tests to cover warnings and warning deduplication. - Move unrelated test fixtures away from deprecated custom-server calls. ### Why? These methods are not part of the documented custom-server API, but existing applications may still rely on them. Warning-only deprecation gives users migration guidance without introducing a breaking runtime change. ### How? Warnings are emitted only through `NextCustomServer`, so framework-owned `NextServer` usage remains quiet. The warning text points `render*` callers toward `app.getRequestHandler()`, `setAssetPrefix()` callers toward configuration, and logging and revalidation callers toward supported application APIs. The tests retain compatibility assertions for existing behavior, add deliberate invocations for previously uncovered methods, verify once-per-process warning deduplication, and remove incidental warning sources in unrelated fixtures. <!-- NEXT_JS_LLM_PR -->
33 lines
832 B
TypeScript
33 lines
832 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('custom-app-render', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
startCommand: 'node server.js',
|
|
serverReadyPattern: /Next mode: (production|development)/,
|
|
dependencies: {
|
|
'get-port': '5.1.1',
|
|
},
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it.each(['/', '/render'])('should render %s', async (page) => {
|
|
const $ = await next.render$(page)
|
|
expect($('#page').data('page')).toBe(page)
|
|
})
|
|
|
|
it('should warn when using the deprecated render method', async () => {
|
|
await next.render('/render')
|
|
await retry(async () => {
|
|
expect(next.cliOutput).toContain(
|
|
'The `app.render()` method is deprecated in custom servers.'
|
|
)
|
|
})
|
|
})
|
|
})
|