Unverified Commit cd333000 authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Await `killApp` in integration tests (#70292)

parent 948f1f1a
......@@ -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)
})
}
......
......@@ -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
}
})
......
......@@ -29,8 +29,8 @@ describe('Configuration', () => {
])
})
afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})
async function get$(path, query) {
......
......@@ -29,8 +29,8 @@ describe('Configuration', () => {
])
})
afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})
async function get$(path, query) {
......
......@@ -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()
})
......
......@@ -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()
......
......@@ -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()
......
......@@ -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'))
})
})
......@@ -32,10 +32,10 @@ describe('Middleware development errors', () => {
})
})
afterEach(() => {
afterEach(async () => {
context.middleware.restore()
if (context.app) {
killApp(context.app)
await killApp(context.app)
}
})
......
......@@ -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()
}
......@@ -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)
}
......
......@@ -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()
}
......
......@@ -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()
}
......@@ -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()
}
......
......@@ -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)
}
......@@ -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)
}
......
......@@ -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)
}
......@@ -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)
}
......
......@@ -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)
}
......@@ -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)
}
......
......@@ -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('/')
})
......@@ -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('/')
}
......@@ -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')
})
......@@ -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')
}
......
......@@ -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()
}
......@@ -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()
}
......
......@@ -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('/')
})
......@@ -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('/')
}
......@@ -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')
})
......@@ -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')
}
......
......@@ -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()
}
......@@ -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()
}
......
......@@ -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 () => {
......
......@@ -18,8 +18,8 @@ describe('MDX-rs Configuration', () => {
context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort)
})
afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
})
it('should render an MDX page correctly', async () => {
expect(await renderViaHTTP(context.appPort, '/')).toMatch(/Hello MDX/)
......@@ -60,8 +60,8 @@ describe('MDX-rs Configuration', () => {
context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort)
})
afterAll(() => {
killApp(context.server)
afterAll(async () => {
await killApp(context.server)
nextConfig.restore()
})
......
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