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() { ...@@ -24,21 +24,21 @@ function runTests() {
app = await launchApp(appDir, appPort, {}) app = await launchApp(appDir, appPort, {})
const data = await makeRequest() const data = await makeRequest()
expect(data).toEqual([{ title: 'Nextjs' }]) expect(data).toEqual([{ title: 'Nextjs' }])
killApp(app) await killApp(app)
}) })
it('should not throw if request body is already parsed in custom middleware', async () => { it('should not throw if request body is already parsed in custom middleware', async () => {
await startServer() await startServer()
const data = await makeRequest() const data = await makeRequest()
expect(data).toEqual([{ title: 'Nextjs' }]) expect(data).toEqual([{ title: 'Nextjs' }])
killApp(server) await killApp(server)
}) })
it("should not throw if request's content-type is invalid", async () => { it("should not throw if request's content-type is invalid", async () => {
await startServer() await startServer()
const status = await makeRequestWithInvalidContentType() const status = await makeRequestWithInvalidContentType()
expect(status).toBe(200) expect(status).toBe(200)
killApp(server) await killApp(server)
}) })
} }
......
...@@ -38,13 +38,13 @@ async function collectStdoutFromBuild(appDir) { ...@@ -38,13 +38,13 @@ async function collectStdoutFromBuild(appDir) {
} }
describe('Config Experimental Warning', () => { describe('Config Experimental Warning', () => {
afterEach(() => { afterEach(async () => {
configFile.write('') configFile.write('')
configFile.delete() configFile.delete()
configFileMjs.write('') configFileMjs.write('')
configFileMjs.delete() configFileMjs.delete()
if (app) { if (app) {
killApp(app) await killApp(app)
app = undefined app = undefined
} }
}) })
......
...@@ -29,8 +29,8 @@ describe('Configuration', () => { ...@@ -29,8 +29,8 @@ describe('Configuration', () => {
]) ])
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
}) })
async function get$(path, query) { async function get$(path, query) {
......
...@@ -29,8 +29,8 @@ describe('Configuration', () => { ...@@ -29,8 +29,8 @@ describe('Configuration', () => {
]) ])
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
}) })
async function get$(path, query) { async function get$(path, query) {
......
...@@ -174,8 +174,8 @@ describe.each([ ...@@ -174,8 +174,8 @@ describe.each([
if (!useHttps) { if (!useHttps) {
describe('HMR with custom server', () => { describe('HMR with custom server', () => {
beforeAll(() => startServer()) beforeAll(() => startServer())
afterAll(() => { afterAll(async () => {
killApp(server) await killApp(server)
indexPg.restore() indexPg.restore()
}) })
......
...@@ -45,9 +45,9 @@ describe('Edge runtime configurable guards', () => { ...@@ -45,9 +45,9 @@ describe('Edge runtime configurable guards', () => {
context.logs = { output: '', stdout: '', stderr: '' } context.logs = { output: '', stdout: '', stderr: '' }
}) })
afterEach(() => { afterEach(async () => {
if (context.app) { if (context.app) {
killApp(context.app) await killApp(context.app)
} }
context.api.restore() context.api.restore()
context.middleware.restore() context.middleware.restore()
......
...@@ -44,9 +44,9 @@ describe('Edge runtime code with imports', () => { ...@@ -44,9 +44,9 @@ describe('Edge runtime code with imports', () => {
await remove(join(__dirname, '../.next')) await remove(join(__dirname, '../.next'))
}) })
afterEach(() => { afterEach(async () => {
if (context.app) { if (context.app) {
killApp(context.app) await killApp(context.app)
} }
context.api.restore() context.api.restore()
context.middleware.restore() context.middleware.restore()
......
...@@ -20,8 +20,8 @@ describe('Empty Project', () => { ...@@ -20,8 +20,8 @@ describe('Empty Project', () => {
expect(res.status).toBe(404) expect(res.status).toBe(404)
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
fs.closeSync(fs.openSync(join(__dirname, '..', 'pages', '.gitkeep'), 'w')) fs.closeSync(fs.openSync(join(__dirname, '..', 'pages', '.gitkeep'), 'w'))
}) })
}) })
...@@ -32,10 +32,10 @@ describe('Middleware development errors', () => { ...@@ -32,10 +32,10 @@ describe('Middleware development errors', () => {
}) })
}) })
afterEach(() => { afterEach(async () => {
context.middleware.restore() context.middleware.restore()
if (context.app) { if (context.app) {
killApp(context.app) await killApp(context.app)
} }
}) })
......
...@@ -133,8 +133,8 @@ describe('Static Image Component Tests for basePath', () => { ...@@ -133,8 +133,8 @@ describe('Static Image Component Tests for basePath', () => {
html = await renderViaHTTP(appPort, '/docs/static-img') html = await renderViaHTTP(appPort, '/docs/static-img')
browser = await webdriver(appPort, '/docs/static-img') browser = await webdriver(appPort, '/docs/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests() runTests()
} }
...@@ -148,8 +148,8 @@ describe('Static Image Component Tests for basePath', () => { ...@@ -148,8 +148,8 @@ describe('Static Image Component Tests for basePath', () => {
html = await renderViaHTTP(appPort, '/docs/static-img') html = await renderViaHTTP(appPort, '/docs/static-img')
browser = await webdriver(appPort, '/docs/static-img') browser = await webdriver(appPort, '/docs/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(true) runTests(true)
} }
......
...@@ -153,8 +153,8 @@ describe('Static Image Component Tests', () => { ...@@ -153,8 +153,8 @@ describe('Static Image Component Tests', () => {
html = await renderViaHTTP(appPort, '/static-img') html = await renderViaHTTP(appPort, '/static-img')
browser = await webdriver(appPort, '/static-img') browser = await webdriver(appPort, '/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests() runTests()
} }
......
...@@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => { ...@@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
...@@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => { ...@@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => {
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
......
...@@ -262,8 +262,8 @@ describe('Static Image Component Tests', () => { ...@@ -262,8 +262,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img') browser = await webdriver(appPort, '/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(false) runTests(false)
} }
...@@ -278,8 +278,8 @@ describe('Static Image Component Tests', () => { ...@@ -278,8 +278,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img') browser = await webdriver(appPort, '/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(true) runTests(true)
} }
......
...@@ -207,8 +207,8 @@ describe('Static Image Component Tests for basePath', () => { ...@@ -207,8 +207,8 @@ describe('Static Image Component Tests for basePath', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/docs/static-img') browser = await webdriver(appPort, '/docs/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(false) runTests(false)
} }
...@@ -223,8 +223,8 @@ describe('Static Image Component Tests for basePath', () => { ...@@ -223,8 +223,8 @@ describe('Static Image Component Tests for basePath', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/docs/static-img') browser = await webdriver(appPort, '/docs/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(true) runTests(true)
} }
......
...@@ -269,8 +269,8 @@ describe('Static Image Component Tests', () => { ...@@ -269,8 +269,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img') browser = await webdriver(appPort, '/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(false) runTests(false)
} }
...@@ -285,8 +285,8 @@ describe('Static Image Component Tests', () => { ...@@ -285,8 +285,8 @@ describe('Static Image Component Tests', () => {
$ = cheerio.load(html) $ = cheerio.load(html)
browser = await webdriver(appPort, '/static-img') browser = await webdriver(appPort, '/static-img')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests(true) runTests(true)
} }
......
...@@ -50,8 +50,8 @@ describe('Image Loader Config', () => { ...@@ -50,8 +50,8 @@ describe('Image Loader Config', () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/') runTests('/')
}) })
...@@ -63,8 +63,8 @@ describe('Image Loader Config', () => { ...@@ -63,8 +63,8 @@ describe('Image Loader Config', () => {
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/') runTests('/')
} }
...@@ -74,8 +74,8 @@ describe('Image Loader Config', () => { ...@@ -74,8 +74,8 @@ describe('Image Loader Config', () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/get-img-props') runTests('/get-img-props')
}) })
...@@ -87,8 +87,8 @@ describe('Image Loader Config', () => { ...@@ -87,8 +87,8 @@ describe('Image Loader Config', () => {
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/get-img-props') runTests('/get-img-props')
} }
......
...@@ -51,8 +51,8 @@ describe('Image Loader Config with Edge Runtime', () => { ...@@ -51,8 +51,8 @@ describe('Image Loader Config with Edge Runtime', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
...@@ -69,8 +69,8 @@ describe('Image Loader Config with Edge Runtime', () => { ...@@ -69,8 +69,8 @@ describe('Image Loader Config with Edge Runtime', () => {
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
......
...@@ -43,8 +43,8 @@ describe('Image Loader Config new', () => { ...@@ -43,8 +43,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/') runTests('/')
}) })
...@@ -56,8 +56,8 @@ describe('Image Loader Config new', () => { ...@@ -56,8 +56,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/') runTests('/')
} }
...@@ -67,8 +67,8 @@ describe('Image Loader Config new', () => { ...@@ -67,8 +67,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/get-img-props') runTests('/get-img-props')
}) })
...@@ -80,8 +80,8 @@ describe('Image Loader Config new', () => { ...@@ -80,8 +80,8 @@ describe('Image Loader Config new', () => {
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
}) })
runTests('/get-img-props') runTests('/get-img-props')
} }
......
...@@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => { ...@@ -76,8 +76,8 @@ describe('Image Component Unicode Image URL', () => {
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
...@@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => { ...@@ -94,8 +94,8 @@ describe('Image Component Unicode Image URL', () => {
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
browser = await webdriver(appPort, '/') browser = await webdriver(appPort, '/')
}) })
afterAll(() => { afterAll(async () => {
killApp(app) await killApp(app)
if (browser) { if (browser) {
browser.close() browser.close()
} }
......
...@@ -34,8 +34,8 @@ const startServer = async (optEnv = {}, opts) => { ...@@ -34,8 +34,8 @@ const startServer = async (optEnv = {}, opts) => {
beforeAll(async () => { beforeAll(async () => {
await startServer() await startServer()
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
}) })
it('should compile pages for SSR', async () => { it('should compile pages for SSR', async () => {
......
...@@ -18,8 +18,8 @@ describe('MDX-rs Configuration', () => { ...@@ -18,8 +18,8 @@ describe('MDX-rs Configuration', () => {
context.appPort = await findPort() context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort) context.server = await launchApp(join(__dirname, '../'), context.appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
}) })
it('should render an MDX page correctly', async () => { it('should render an MDX page correctly', async () => {
expect(await renderViaHTTP(context.appPort, '/')).toMatch(/Hello MDX/) expect(await renderViaHTTP(context.appPort, '/')).toMatch(/Hello MDX/)
...@@ -60,8 +60,8 @@ describe('MDX-rs Configuration', () => { ...@@ -60,8 +60,8 @@ describe('MDX-rs Configuration', () => {
context.appPort = await findPort() context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort) context.server = await launchApp(join(__dirname, '../'), context.appPort)
}) })
afterAll(() => { afterAll(async () => {
killApp(context.server) await killApp(context.server)
nextConfig.restore() 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