From 83f81fbaeba75518cf3a28d8f0198d1f02febe79 Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Tue, 17 Oct 2023 23:41:45 -0500 Subject: [PATCH] chore(repo): Add buildOutput property on Application instead of accepting a custom log --- integration/models/application.ts | 16 +++++++++++++--- integration/tests/next-build.test.ts | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/integration/models/application.ts b/integration/models/application.ts index d5c50b30e0c..992cfd92b02 100644 --- a/integration/models/application.ts +++ b/integration/models/application.ts @@ -16,6 +16,7 @@ export const application = (config: ApplicationConfig, appDirPath: string, appDi const now = Date.now(); const stdoutFilePath = path.resolve(appDirPath, `e2e.${now}.log`); const stderrFilePath = path.resolve(appDirPath, `e2e.${now}.err.log`); + let buildOutput = ''; const self = { name, @@ -68,9 +69,18 @@ export const application = (config: ApplicationConfig, appDirPath: string, appDi state.serverUrl = serverUrl; return { port, serverUrl, pid: proc.pid }; }, - build: async ({ log }: { log?: (msg: string) => void } = {}) => { - const finalLog = log ?? logger.child({ prefix: 'build' }).info; - await run(scripts.build, { cwd: appDirPath, log: finalLog }); + build: async () => { + const log = logger.child({ prefix: 'build' }).info; + await run(scripts.build, { + cwd: appDirPath, + log: (msg: string) => { + buildOutput += `\n${msg}`; + log(msg); + }, + }); + }, + get buildOutput() { + return buildOutput; }, serve: async (opts: { port?: number; manualStart?: boolean } = {}) => { const port = opts.port || (await getPort()); diff --git a/integration/tests/next-build.test.ts b/integration/tests/next-build.test.ts index 1c0a01d8ef6..7f5cf9394e0 100644 --- a/integration/tests/next-build.test.ts +++ b/integration/tests/next-build.test.ts @@ -51,7 +51,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) .commit(); await app.setup(); await app.withEnv(appConfigs.envs.withEmailCodes); - await app.build({ log: msg => output.push(msg) }); + await app.build(); }); test.afterAll(async () => { @@ -65,7 +65,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) * Using /_not-found as it is an internal page that should statically render by default. * This is a good indicator of whether or not the entire app has been opted-in to dynamic rendering. */ - const notFoundPageLine = output.find(msg => msg.includes('/_not-found')); + const notFoundPageLine = app.buildOutput.split('\n').find(msg => msg.includes('/_not-found')); expect(notFoundPageLine).not.toContain(dynamicIndicator); });