-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add standalone testcase for ipv6 hostnames (#53999)
This adds a test case for ipv6 hostnames in standalone mode - Follow up to #53131
- Loading branch information
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AppPage() { | ||
return <div>Hello from App</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html> | ||
<head /> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { NextInstance, createNext } from 'e2e-utils' | ||
import fs from 'fs-extra' | ||
import glob from 'glob' | ||
import { | ||
findPort, | ||
initNextServerScript, | ||
killApp, | ||
renderViaHTTP, | ||
} from 'next-test-utils' | ||
import { join } from 'path' | ||
|
||
describe('standalone mode: ipv6 hostname', () => { | ||
let next: NextInstance | ||
let server | ||
let appPort | ||
let output = '' | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: __dirname, | ||
}) | ||
await next.stop() | ||
|
||
await fs.move( | ||
join(next.testDir, '.next/standalone'), | ||
join(next.testDir, 'standalone') | ||
) | ||
|
||
for (const file of await fs.readdir(next.testDir)) { | ||
if (file !== 'standalone') { | ||
await fs.remove(join(next.testDir, file)) | ||
console.log('removed', file) | ||
} | ||
} | ||
const files = glob.sync('**/*', { | ||
cwd: join(next.testDir, 'standalone/.next/server/pages'), | ||
dot: true, | ||
}) | ||
|
||
for (const file of files) { | ||
if (file.endsWith('.json') || file.endsWith('.html')) { | ||
await fs.remove(join(next.testDir, '.next/server', file)) | ||
} | ||
} | ||
|
||
const testServer = join(next.testDir, 'standalone/server.js') | ||
appPort = await findPort() | ||
server = await initNextServerScript( | ||
testServer, | ||
/ready started server on/, | ||
{ | ||
...process.env, | ||
HOSTNAME: '::', | ||
PORT: appPort, | ||
}, | ||
undefined, | ||
{ | ||
cwd: next.testDir, | ||
onStdout(msg) { | ||
output += msg | ||
}, | ||
onStderr(msg) { | ||
output += msg | ||
}, | ||
} | ||
) | ||
}) | ||
afterAll(async () => { | ||
await next.destroy() | ||
if (server) await killApp(server) | ||
}) | ||
|
||
it('should load the page without any errors', async () => { | ||
expect(output).toContain(`started server on`) | ||
|
||
let html = await renderViaHTTP(appPort, '/app-page') | ||
expect(html).toContain('Hello from App') | ||
|
||
html = await renderViaHTTP(appPort, '/pages-page') | ||
expect(html).toContain('Hello from Pages') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
output: 'standalone', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AppPage() { | ||
return <div>Hello from Pages</div> | ||
} |