Files
next.js/test/development/experimental-https-server/https-server.provided-key.test.ts
T
Zack TannerandGitHub adc413b3fb add experimental https support to next dev (#54016)
This adds an `--experimental-https` flag to `next dev` which will generate a self-signed certificate via [mkcert](https://github.com/FiloSottile/mkcert) and use it for the dev server.

also supports passing in pre-existing certs via `--experimental-https-cert` and `--experimental-https-key`

x-ref: https://github.com/vercel/next.js/discussions/33768 https://github.com/vercel/next.js/discussions/10935
2023-08-19 01:04:06 +00:00

30 lines
996 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
import https from 'https'
import { renderViaHTTP } from 'next-test-utils'
createNextDescribe(
'experimental-https-server (provided certificate)',
{
files: __dirname,
startCommand:
'yarn next dev --experimental-https --experimental-https-key ./certificates/localhost-key.pem --experimental-https-cert ./certificates/localhost.pem',
},
({ next }) => {
const agent = new https.Agent({
rejectUnauthorized: false,
})
it('should successfully load the app in app dir', async () => {
expect(next.url).toInclude('https://')
const html = await renderViaHTTP(next.url, '/1', undefined, { agent })
expect(html).toContain('Hello from App')
})
it('should successfully load the app in pages dir', async () => {
expect(next.url).toInclude('https://')
const html = await renderViaHTTP(next.url, '/2', undefined, { agent })
expect(html).toContain('Hello from Pages')
})
}
)