Skip to content

Commit

Permalink
Await killApp in integration tests (#70292)
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Sep 20, 2024
1 parent 948f1f1 commit cd33300
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions test/integration/api-body-parser/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ function runTests() {
app = await launchApp(appDir, appPort, {})
const data = await makeRequest()
expect(data).toEqual([{ title: 'Nextjs' }])
killApp(app)
await killApp(app)
})

it('should not throw if request body is already parsed in custom middleware', async () => {
await startServer()
const data = await makeRequest()
expect(data).toEqual([{ title: 'Nextjs' }])
killApp(server)
await killApp(server)
})

it("should not throw if request's content-type is invalid", async () => {
await startServer()
const status = await makeRequestWithInvalidContentType()
expect(status).toBe(200)
killApp(server)
await killApp(server)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ async function collectStdoutFromBuild(appDir) {
}

describe('Config Experimental Warning', () => {
afterEach(() => {
afterEach(async () => {
configFile.write('')
configFile.delete()
configFileMjs.write('')
configFileMjs.delete()
if (app) {
killApp(app)
await killApp(app)
app = undefined
}
})
Expand Down
4 changes: 2 additions & 2 deletions test/integration/config-mjs/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Configuration', () => {
])
})

afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})

async function get$(path, query) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/config/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Configuration', () => {
])
})

afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})

async function get$(path, query) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/custom-server/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ describe.each([
if (!useHttps) {
describe('HMR with custom server', () => {
beforeAll(() => startServer())
afterAll(() => {
killApp(server)
afterAll(async () => {
await killApp(server)
indexPg.restore()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe('Edge runtime configurable guards', () => {
context.logs = { output: '', stdout: '', stderr: '' }
})

afterEach(() => {
afterEach(async () => {
if (context.app) {
killApp(context.app)
await killApp(context.app)
}
context.api.restore()
context.middleware.restore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ describe('Edge runtime code with imports', () => {
await remove(join(__dirname, '../.next'))
})

afterEach(() => {
afterEach(async () => {
if (context.app) {
killApp(context.app)
await killApp(context.app)
}
context.api.restore()
context.middleware.restore()
Expand Down
4 changes: 2 additions & 2 deletions test/integration/empty-project/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('Empty Project', () => {
expect(res.status).toBe(404)
})

afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
fs.closeSync(fs.openSync(join(__dirname, '..', 'pages', '.gitkeep'), 'w'))
})
})
4 changes: 2 additions & 2 deletions test/integration/middleware-dev-update/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ describe('Middleware development errors', () => {
})
})

afterEach(() => {
afterEach(async () => {
context.middleware.restore()
if (context.app) {
killApp(context.app)
await killApp(context.app)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ describe('Static Image Component Tests for basePath', () => {
html = await renderViaHTTP(appPort, '/docs/static-img')
browser = await webdriver(appPort, '/docs/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests()
}
Expand All @@ -148,8 +148,8 @@ describe('Static Image Component Tests for basePath', () => {
html = await renderViaHTTP(appPort, '/docs/static-img')
browser = await webdriver(appPort, '/docs/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ describe('Static Image Component Tests', () => {
html = await renderViaHTTP(appPort, '/static-img')
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests()
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-legacy/unicode/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => {
app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand All @@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => {
app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-new/app-dir/test/static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(false)
}
Expand All @@ -278,8 +278,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(true)
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-new/base-path/test/static.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ describe('Static Image Component Tests for basePath', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/docs/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(false)
}
Expand All @@ -223,8 +223,8 @@ describe('Static Image Component Tests for basePath', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/docs/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(true)
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-new/default/test/static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(false)
}
Expand All @@ -285,8 +285,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe('Image Loader Config', () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/')
})
Expand All @@ -63,8 +63,8 @@ describe('Image Loader Config', () => {
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/')
}
Expand All @@ -74,8 +74,8 @@ describe('Image Loader Config', () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/get-img-props')
})
Expand All @@ -87,8 +87,8 @@ describe('Image Loader Config', () => {
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/get-img-props')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ describe('Image Loader Config with Edge Runtime', () => {
app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand All @@ -69,8 +69,8 @@ describe('Image Loader Config with Edge Runtime', () => {
app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand Down
16 changes: 8 additions & 8 deletions test/integration/next-image-new/loader-config/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/')
})
Expand All @@ -56,8 +56,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/')
}
Expand All @@ -67,8 +67,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/get-img-props')
})
Expand All @@ -80,8 +80,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
})
runTests('/get-img-props')
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/next-image-new/unicode/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => {
app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand All @@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => {
app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/')
})
afterAll(() => {
killApp(app)
afterAll(async () => {
await killApp(app)
if (browser) {
browser.close()
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/ondemand/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const startServer = async (optEnv = {}, opts) => {
beforeAll(async () => {
await startServer()
})
afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})

it('should compile pages for SSR', async () => {
Expand Down
Loading

0 comments on commit cd33300

Please sign in to comment.