From 7a18bdcb21e1ec0ab2462d3e52ace7cb2c1fa228 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Mon, 21 Mar 2022 14:03:51 -0700 Subject: [PATCH] test(integration): emit console error when test fails --- test/integration/production/test/index.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index 5276dbf5db56..3bbfea17f15b 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -26,6 +26,7 @@ import dynamicImportTests from './dynamic' import processEnv from './process-env' import security from './security' import { promisify } from 'util' +import { error } from 'console' const glob = promisify(globOriginal) @@ -53,10 +54,14 @@ describe('Production Usage', () => { context.appPort = appPort app = await nextStart(appDir, appPort, { cwd: appDir }) output = (result.stderr || '') + (result.stdout || '') - console.log(output) if (result.code !== 0) { + error(output) throw new Error(`Failed to build, exited with code ${result.code}`) + } else { + // Note: jest captures calls to console and only emits when there's assertion fails, + // so this won't log anything for normal test execution path. + console.log(output) } }) afterAll(async () => {