Skip to content

Commit 3d3812e

Browse files
committed
Remove portfinder from NextJS tests.
1 parent 6ae5375 commit 3d3812e

File tree

1 file changed

+7
-7
lines changed
  • packages/nextjs/test/integration/test/server/utils

1 file changed

+7
-7
lines changed

packages/nextjs/test/integration/test/server/utils/helpers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { getPortPromise } from 'portfinder';
21
import { TestEnv } from '../../../../../../node-integration-tests/utils';
32
import * as http from 'http';
43
import * as path from 'path';
54
import { createServer, Server } from 'http';
65
import { parse } from 'url';
76
import next from 'next';
7+
import { AddressInfo } from 'net';
88

99
// Type not exported from NextJS
1010
// @ts-ignore
@@ -24,9 +24,10 @@ export const createNextServer = async config => {
2424
});
2525
};
2626

27-
export const startServer = async (server: Server, port: string | number) => {
28-
return new Promise(resolve => {
29-
server.listen(port || 0, () => {
27+
export const startServer = async (server: Server) => {
28+
return new Promise<{ server: http.Server; url: string }>(resolve => {
29+
server.listen(0, () => {
30+
const port = (server.address() as AddressInfo).port;
3031
const url = `http://localhost:${port}`;
3132
resolve({ server, url });
3233
});
@@ -39,7 +40,6 @@ export class NextTestEnv extends TestEnv {
3940
}
4041

4142
public static async init(): Promise<NextTestEnv> {
42-
const port = await getPortPromise();
4343
const server = await createNextServer({
4444
dev: false,
4545
dir: path.resolve(__dirname, '../../..'),
@@ -50,8 +50,8 @@ export class NextTestEnv extends TestEnv {
5050
conf: path.resolve(__dirname, '../../next.config.js'),
5151
});
5252

53-
await startServer(server, port);
53+
const { url } = await startServer(server);
5454

55-
return new NextTestEnv(server, `http://localhost:${port}`);
55+
return new NextTestEnv(server, url);
5656
}
5757
}

0 commit comments

Comments
 (0)