diff --git a/test/lib/next-test-utils.ts b/test/lib/next-test-utils.ts index af93d6068b..a353c0c87c 100644 --- a/test/lib/next-test-utils.ts +++ b/test/lib/next-test-utils.ts @@ -529,6 +529,9 @@ export async function killApp( instance?: ChildProcess, signal: NodeJS.Signals | number = 'SIGKILL' ) { + if (!instance) { + return + } if ( instance?.pid && instance.exitCode === null && @@ -558,7 +561,10 @@ export async function startApp(app: NextServer) { return server } -export async function stopApp(server: http.Server) { +export async function stopApp(server: http.Server | undefined) { + if (!server) { + return + } if (server['__app']) { await server['__app'].close() } diff --git a/test/production/bfcache-routing/index.test.ts b/test/production/bfcache-routing/index.test.ts index 6c816e8952..4df1876bba 100644 --- a/test/production/bfcache-routing/index.test.ts +++ b/test/production/bfcache-routing/index.test.ts @@ -22,9 +22,7 @@ describe('bfcache-routing', () => { }) afterAll(() => { - if (app) { - stopApp(app) - } + stopApp(app) }) it('should not suspend indefinitely when page is restored from bfcache after an mpa navigation', async () => {