Unverified Commit eea3adc5 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

fix rsc test suite runner (#33745)

parent 5f96a0b1
...@@ -221,8 +221,8 @@ const customAppPageSuite = { ...@@ -221,8 +221,8 @@ const customAppPageSuite = {
expect(indexFlight).toContain('container-server') expect(indexFlight).toContain('container-server')
}) })
}, },
before: () => appServerPage.write(rscAppPage), beforeAll: () => appServerPage.write(rscAppPage),
after: () => appServerPage.delete(), afterAll: () => appServerPage.delete(),
} }
runSuite('Custom App', 'dev', customAppPageSuite) runSuite('Custom App', 'dev', customAppPageSuite)
...@@ -267,8 +267,8 @@ describe('concurrentFeatures - dev', () => { ...@@ -267,8 +267,8 @@ describe('concurrentFeatures - dev', () => {
const cssSuite = { const cssSuite = {
runTests: css, runTests: css,
before: () => appPage.write(appWithGlobalCss), beforeAll: () => appPage.write(appWithGlobalCss),
after: () => appPage.delete(), afterAll: () => appPage.delete(),
} }
runSuite('CSS', 'dev', cssSuite) runSuite('CSS', 'dev', cssSuite)
...@@ -286,8 +286,8 @@ const documentSuite = { ...@@ -286,8 +286,8 @@ const documentSuite = {
) )
}) })
}, },
before: () => documentPage.write(documentWithGip), beforeAll: () => documentPage.write(documentWithGip),
after: () => documentPage.delete(), afterAll: () => documentPage.delete(),
} }
runSuite('document', 'dev', documentSuite) runSuite('document', 'dev', documentSuite)
...@@ -333,28 +333,29 @@ async function runBasicTests(context, env) { ...@@ -333,28 +333,29 @@ async function runBasicTests(context, env) {
streaming(context) streaming(context)
} }
function runSuite(suiteName, env, { runTests, before, after }) { function runSuite(suiteName, env, options) {
const context = { appDir } const context = { appDir }
describe(`${suiteName} ${env}`, () => { describe(`${suiteName} ${env}`, () => {
if (env === 'prod') { if (env === 'prod') {
beforeAll(async () => { beforeAll(async () => {
before?.() options.beforeAll?.()
context.appPort = await findPort() context.appPort = await findPort()
context.server = await nextDev(context.appDir, context.appPort) await nextBuild(context.appDir)
context.server = await nextStart(context.appDir, context.appPort)
}) })
} }
if (env === 'dev') { if (env === 'dev') {
beforeAll(async () => { beforeAll(async () => {
before?.() options.beforeAll?.()
context.appPort = await findPort() context.appPort = await findPort()
context.server = await nextDev(context.appDir, context.appPort) context.server = await nextDev(context.appDir, context.appPort)
}) })
} }
afterAll(async () => { afterAll(async () => {
after?.() options.afterAll?.()
await killApp(context.server) await killApp(context.server)
}) })
runTests(context, env) options.runTests(context, env)
}) })
} }
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