mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
6ba71046b0
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.
25 lines
916 B
TypeScript
25 lines
916 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { renderViaRawHTTP } from 'next-test-utils'
|
|
|
|
describe('experimental-https-server (provided certificate)', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
startCommand: `pnpm next dev --experimental-https --experimental-https-key ./certificates/localhost-key.pem --experimental-https-cert ./certificates/localhost.pem`,
|
|
})
|
|
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')
|
|
})
|
|
})
|