Skip to content

Commit

Permalink
chore(repo): Add buildOutput property on Application instead of accep…
Browse files Browse the repository at this point in the history
…ting a custom log
  • Loading branch information
brkalow committed Oct 18, 2023
1 parent 9ebce0a commit 83f81fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions integration/models/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions integration/tests/next-build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
});
Expand Down

0 comments on commit 83f81fb

Please sign in to comment.