Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(nexttestsetup): teardown nextinstance gracefully #55144

Merged
merged 3 commits into from Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/lib/e2e-utils.ts
Expand Up @@ -233,7 +233,12 @@ export function nextTestSetup(
next = await createNext(options)
})
afterAll(async () => {
await next.destroy()
// Gracefully destroy the instance if `createNext` success.
// If next instnace is not available, it's likely beforeAll hook failed and unnecessariliy throws another error
// by attempting to destroy on undefined.
if (next) {
await next.destroy()
}
})
}

Expand Down
4 changes: 3 additions & 1 deletion test/lib/next-test-utils.ts
Expand Up @@ -536,7 +536,9 @@ export async function killProcess(pid: number): Promise<void> {

// Kill a launched app
export async function killApp(instance: ChildProcess) {
await killProcess(instance.pid)
if (instance && instance.pid) {
await killProcess(instance.pid)
}
}

export async function startApp(app: NextServer) {
Expand Down