Files
vercel__next.js/test/development/experimental-https-server/https-server.generated-key.test.ts
Sebastian "Sebbie" Silbermann 6ba71046b0 [test] Move the harness off node-fetch (#98195)
Node.js ships with a built-in `fetch` now so `node-fetch` is no longer
necessary. Mostly motivated by tracing Node.js deprecation warnings
which originated from `node-fetch` by calling the deprecated
`url.parse`.

Call sites keep working through a compatibility type on `fetchViaHTTP`
that translates node-fetch-only options: Instead of `agent` we pass to
`http(s)` directly, `timeout` becomes `AbortSignal.timeout`, and Node.js
readable streams are accepted as bodies with `duplex: 'half'` set
automatically.

The `abort-controller` polyfill is dropped since its signal type
predates the current AbortSignal and undici would not honor it.
`node-fetch` stays installed because `scripts/generate-release-log.mjs`,
`scripts/reset-project.mjs`, and `scripts/update-google-fonts.js` still
import it (follow-up material). Fixture apps will be migrated
separately.
2026-09-10 13:50:35 +02:00

43 lines
1.3 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { renderViaRawHTTP } from 'next-test-utils'
describe('experimental-https-server (generated certificate)', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
startCommand: 'pnpm next dev --experimental-https',
skipStart: !process.env.NEXT_TEST_CI,
})
if (skipped) return
if (!process.env.NEXT_TEST_CI) {
console.warn('only runs on CI as it requires administrator privileges')
it('only runs on CI as it requires administrator privileges', () => {})
return
}
it('should successfully load the app in app dir', async () => {
expect(next.url).toInclude('https://')
const html = await renderViaRawHTTP(next.url, '/1', {
rejectUnauthorized: false,
})
expect(html).toContain('Hello from App')
})
it('should successfully load the app in pages dir', async () => {
expect(next.url).toInclude('https://')
const html = await renderViaRawHTTP(next.url, '/2', {
rejectUnauthorized: false,
})
expect(html).toContain('Hello from Pages')
})
it('should successfully reuse generated certificates', async () => {
await next.stop()
await next.start()
expect(next.url).toInclude('https://')
expect(next.cliOutput).toContain(
'Using already generated self signed certificate'
)
})
})