diff --git a/lib/builder/builder.mjs b/lib/builder/builder.mjs index 7ca34f801f..d37647b628 100644 --- a/lib/builder/builder.mjs +++ b/lib/builder/builder.mjs @@ -39,9 +39,8 @@ export default class Builder { this.webpackHotMiddleware = null this.filesWatcher = null this.customFilesWatcher = null - this.spinner = createSpinner({ - minimal: this.options.minimalCLI - }) + this.spinner = createSpinner({ minimal: this.options.minimalCLI }) + this.spinner.enabled = !this.options.test // Mute stats on dev this.webpackStats = this.options.dev ? false : this.options.build.stats diff --git a/lib/common/utils.mjs b/lib/common/utils.mjs index cd9b858f38..15d9411a4c 100644 --- a/lib/common/utils.mjs +++ b/lib/common/utils.mjs @@ -38,19 +38,21 @@ export const createSpinner = function ({ minimal = false }) { // Creare a minimal fallback for test and CI environments + const ctx = { enabled: true } + // eslint-disable-next-line no-console - const logger = (tag) => (...args) => console.log( + const createLogger = (tag, ctx) => (...args) => ctx.enabled && console.log( `[${(new Date().toISOString)()}]`, _.padEnd(`[${tag}]`, 10), ...args ) - return { - start: logger('START'), - fail: logger('FAIL'), - succeed: logger('SUCCESS'), - info: logger('INFO') - } + return Object.assign(ctx, { + start: createLogger('START', ctx), + fail: createLogger('FAIL', ctx), + succeed: createLogger('SUCCESS', ctx), + info: createLogger('INFO', ctx) + }) } export const encodeHtml = function encodeHtml(str) {