Unverified Commit 78505fcb authored by Sam Ko's avatar Sam Ko Committed by GitHub

chore(test): add types to tests (#66724)

## Why?

Adding types to test—building on this
[PR](https://github.com/vercel/next.js/pull/65722).
parent edf8cc52
...@@ -10,11 +10,12 @@ import { ...@@ -10,11 +10,12 @@ import {
initNextServerScript, initNextServerScript,
killApp, killApp,
} from 'next-test-utils' } from 'next-test-utils'
import { ChildProcess } from 'child_process'
describe('required server files app router', () => { describe('required server files app router', () => {
let next: NextInstance let next: NextInstance
let server let server: ChildProcess
let appPort let appPort: number | string
const setupNext = async ({ const setupNext = async ({
nextEnv, nextEnv,
...@@ -83,14 +84,17 @@ describe('required server files app router', () => { ...@@ -83,14 +84,17 @@ describe('required server files app router', () => {
/- Local:/, /- Local:/,
{ {
...process.env, ...process.env,
PORT: appPort, PORT: `${appPort}`,
}, },
undefined, undefined,
{ {
cwd: next.testDir, cwd: next.testDir,
} }
) )
appPort = `http://127.0.0.1:${appPort}`
if (process.platform === 'darwin') {
appPort = `http://127.0.0.1:${appPort}`
}
} }
beforeAll(async () => { beforeAll(async () => {
......
...@@ -14,11 +14,12 @@ import { ...@@ -14,11 +14,12 @@ import {
waitFor, waitFor,
} from 'next-test-utils' } from 'next-test-utils'
import nodeFetch from 'node-fetch' import nodeFetch from 'node-fetch'
import { ChildProcess } from 'child_process'
describe('required server files i18n', () => { describe('required server files i18n', () => {
let next: NextInstance let next: NextInstance
let server let server: ChildProcess
let appPort let appPort: number | string
let errors = [] let errors = []
let requiredFilesManifest let requiredFilesManifest
...@@ -117,7 +118,7 @@ describe('required server files i18n', () => { ...@@ -117,7 +118,7 @@ describe('required server files i18n', () => {
/- Local:/, /- Local:/,
{ {
...process.env, ...process.env,
PORT: appPort, PORT: `${appPort}`,
}, },
undefined, undefined,
{ {
...@@ -127,7 +128,12 @@ describe('required server files i18n', () => { ...@@ -127,7 +128,12 @@ describe('required server files i18n', () => {
}, },
} }
) )
if (process.platform === 'darwin') {
appPort = `http://127.0.0.1:${appPort}`
}
}) })
afterAll(async () => { afterAll(async () => {
await next.destroy() await next.destroy()
if (server) await killApp(server) if (server) await killApp(server)
......
...@@ -101,7 +101,10 @@ describe('required server files app router', () => { ...@@ -101,7 +101,10 @@ describe('required server files app router', () => {
cwd: next.testDir, cwd: next.testDir,
} }
) )
appPort = `http://127.0.0.1:${appPort}`
if (process.platform === 'darwin') {
appPort = `http://127.0.0.1:${appPort}`
}
} }
beforeAll(async () => { beforeAll(async () => {
......
...@@ -15,11 +15,12 @@ import { ...@@ -15,11 +15,12 @@ import {
retry, retry,
waitFor, waitFor,
} from 'next-test-utils' } from 'next-test-utils'
import { ChildProcess } from 'child_process'
describe('required server files', () => { describe('required server files', () => {
let next: NextInstance let next: NextInstance
let server let server: ChildProcess
let appPort let appPort: number | string
let errors = [] let errors = []
let stderr = '' let stderr = ''
let requiredFilesManifest let requiredFilesManifest
...@@ -124,7 +125,7 @@ describe('required server files', () => { ...@@ -124,7 +125,7 @@ describe('required server files', () => {
{ {
...process.env, ...process.env,
ENV_FROM_HOST: 'FOOBAR', ENV_FROM_HOST: 'FOOBAR',
PORT: appPort, PORT: `${appPort}`,
}, },
undefined, undefined,
{ {
...@@ -1296,7 +1297,7 @@ describe('required server files', () => { ...@@ -1296,7 +1297,7 @@ describe('required server files', () => {
/- Local:/, /- Local:/,
{ {
...process.env, ...process.env,
PORT: appPort, PORT: `${appPort}`,
}, },
undefined, undefined,
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment