Skip to content

Commit

Permalink
fix rsc test suite runner (vercel#33745)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored and natew committed Feb 16, 2022
1 parent 528b0e0 commit 385b6e8
Showing 1 changed file with 13 additions and 12 deletions.
Expand Up @@ -221,8 +221,8 @@ const customAppPageSuite = {
expect(indexFlight).toContain('container-server')
})
},
before: () => appServerPage.write(rscAppPage),
after: () => appServerPage.delete(),
beforeAll: () => appServerPage.write(rscAppPage),
afterAll: () => appServerPage.delete(),
}

runSuite('Custom App', 'dev', customAppPageSuite)
Expand Down Expand Up @@ -267,8 +267,8 @@ describe('concurrentFeatures - dev', () => {

const cssSuite = {
runTests: css,
before: () => appPage.write(appWithGlobalCss),
after: () => appPage.delete(),
beforeAll: () => appPage.write(appWithGlobalCss),
afterAll: () => appPage.delete(),
}

runSuite('CSS', 'dev', cssSuite)
Expand All @@ -286,8 +286,8 @@ const documentSuite = {
)
})
},
before: () => documentPage.write(documentWithGip),
after: () => documentPage.delete(),
beforeAll: () => documentPage.write(documentWithGip),
afterAll: () => documentPage.delete(),
}

runSuite('document', 'dev', documentSuite)
Expand Down Expand Up @@ -333,28 +333,29 @@ async function runBasicTests(context, env) {
streaming(context)
}

function runSuite(suiteName, env, { runTests, before, after }) {
function runSuite(suiteName, env, options) {
const context = { appDir }
describe(`${suiteName} ${env}`, () => {
if (env === 'prod') {
beforeAll(async () => {
before?.()
options.beforeAll?.()
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') {
beforeAll(async () => {
before?.()
options.beforeAll?.()
context.appPort = await findPort()
context.server = await nextDev(context.appDir, context.appPort)
})
}
afterAll(async () => {
after?.()
options.afterAll?.()
await killApp(context.server)
})

runTests(context, env)
options.runTests(context, env)
})
}

0 comments on commit 385b6e8

Please sign in to comment.