fix(test-utils): prevent orphaned processes and use baseURL when loading (#18623)

This commit is contained in:
Daniel Roe 2023-01-30 12:21:02 -08:00 committed by GitHub
parent a0085b70a3
commit c9d0b2f6be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,12 +30,13 @@ export async function startServer () {
for (let i = 0; i < 50; i++) { for (let i = 0; i < 50; i++) {
await new Promise(resolve => setTimeout(resolve, 100)) await new Promise(resolve => setTimeout(resolve, 100))
try { try {
const res = await $fetch('/') const res = await $fetch(ctx.nuxt!.options.app.baseURL)
if (!res.includes('__NUXT_LOADING__')) { if (!res.includes('__NUXT_LOADING__')) {
return return
} }
} catch {} } catch {}
} }
ctx.serverProcess.kill()
throw new Error('Timeout waiting for dev server!') throw new Error('Timeout waiting for dev server!')
} else { } else {
ctx.serverProcess = execa('node', [ ctx.serverProcess = execa('node', [