From 78505fcb785f9601c6e5218834479d84237d819f Mon Sep 17 00:00:00 2001 From: Sam Ko Date: Mon, 10 Jun 2024 14:54:56 -0700 Subject: [PATCH] chore(test): add types to tests (#66724) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why? Adding types to test—building on this [PR](https://github.com/vercel/next.js/pull/65722). --- .../required-server-files-app.test.ts | 12 ++++++++---- .../required-server-files-i18n.test.ts | 12 +++++++++--- .../required-server-files-ppr.test.ts | 5 ++++- .../required-server-files.test.ts | 9 +++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/test/production/standalone-mode/required-server-files/required-server-files-app.test.ts b/test/production/standalone-mode/required-server-files/required-server-files-app.test.ts index 410fa183b3f1b..e2f45d7a2a70b 100644 --- a/test/production/standalone-mode/required-server-files/required-server-files-app.test.ts +++ b/test/production/standalone-mode/required-server-files/required-server-files-app.test.ts @@ -10,11 +10,12 @@ import { initNextServerScript, killApp, } from 'next-test-utils' +import { ChildProcess } from 'child_process' describe('required server files app router', () => { let next: NextInstance - let server - let appPort + let server: ChildProcess + let appPort: number | string const setupNext = async ({ nextEnv, @@ -83,14 +84,17 @@ describe('required server files app router', () => { /- Local:/, { ...process.env, - PORT: appPort, + PORT: `${appPort}`, }, undefined, { cwd: next.testDir, } ) - appPort = `http://127.0.0.1:${appPort}` + + if (process.platform === 'darwin') { + appPort = `http://127.0.0.1:${appPort}` + } } beforeAll(async () => { diff --git a/test/production/standalone-mode/required-server-files/required-server-files-i18n.test.ts b/test/production/standalone-mode/required-server-files/required-server-files-i18n.test.ts index 12da3649353d7..941bd06e3bcb2 100644 --- a/test/production/standalone-mode/required-server-files/required-server-files-i18n.test.ts +++ b/test/production/standalone-mode/required-server-files/required-server-files-i18n.test.ts @@ -14,11 +14,12 @@ import { waitFor, } from 'next-test-utils' import nodeFetch from 'node-fetch' +import { ChildProcess } from 'child_process' describe('required server files i18n', () => { let next: NextInstance - let server - let appPort + let server: ChildProcess + let appPort: number | string let errors = [] let requiredFilesManifest @@ -117,7 +118,7 @@ describe('required server files i18n', () => { /- Local:/, { ...process.env, - PORT: appPort, + PORT: `${appPort}`, }, undefined, { @@ -127,7 +128,12 @@ describe('required server files i18n', () => { }, } ) + + if (process.platform === 'darwin') { + appPort = `http://127.0.0.1:${appPort}` + } }) + afterAll(async () => { await next.destroy() if (server) await killApp(server) diff --git a/test/production/standalone-mode/required-server-files/required-server-files-ppr.test.ts b/test/production/standalone-mode/required-server-files/required-server-files-ppr.test.ts index 69e6ab764fb2f..06142d7e9a8fe 100644 --- a/test/production/standalone-mode/required-server-files/required-server-files-ppr.test.ts +++ b/test/production/standalone-mode/required-server-files/required-server-files-ppr.test.ts @@ -101,7 +101,10 @@ describe('required server files app router', () => { cwd: next.testDir, } ) - appPort = `http://127.0.0.1:${appPort}` + + if (process.platform === 'darwin') { + appPort = `http://127.0.0.1:${appPort}` + } } beforeAll(async () => { diff --git a/test/production/standalone-mode/required-server-files/required-server-files.test.ts b/test/production/standalone-mode/required-server-files/required-server-files.test.ts index 934ad318baf82..7f457ce3c8593 100644 --- a/test/production/standalone-mode/required-server-files/required-server-files.test.ts +++ b/test/production/standalone-mode/required-server-files/required-server-files.test.ts @@ -15,11 +15,12 @@ import { retry, waitFor, } from 'next-test-utils' +import { ChildProcess } from 'child_process' describe('required server files', () => { let next: NextInstance - let server - let appPort + let server: ChildProcess + let appPort: number | string let errors = [] let stderr = '' let requiredFilesManifest @@ -124,7 +125,7 @@ describe('required server files', () => { { ...process.env, ENV_FROM_HOST: 'FOOBAR', - PORT: appPort, + PORT: `${appPort}`, }, undefined, { @@ -1296,7 +1297,7 @@ describe('required server files', () => { /- Local:/, { ...process.env, - PORT: appPort, + PORT: `${appPort}`, }, undefined, {