Skip to content

Commit

Permalink
Remove portfinder from NextJS tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Jul 22, 2023
1 parent 6ae5375 commit 5f6316b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [10, 12, 14, 16, 18]
node: [10, 12, 14, 16, 18, 20]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v3
Expand Down
14 changes: 7 additions & 7 deletions packages/nextjs/test/integration/test/server/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getPortPromise } from 'portfinder';
import { TestEnv } from '../../../../../../node-integration-tests/utils';
import * as http from 'http';
import * as path from 'path';
import { createServer, Server } from 'http';
import { parse } from 'url';
import next from 'next';
import { AddressInfo } from 'net';

// Type not exported from NextJS
// @ts-ignore
Expand All @@ -24,9 +24,10 @@ export const createNextServer = async config => {
});
};

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

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

await startServer(server, port);
const { url } = await startServer(server);

return new NextTestEnv(server, `http://localhost:${port}`);
return new NextTestEnv(server, url);
}
}

0 comments on commit 5f6316b

Please sign in to comment.