diff --git a/lib/builder/builder.mjs b/lib/builder/builder.mjs index 02060e9af7..091a05857a 100644 --- a/lib/builder/builder.mjs +++ b/lib/builder/builder.mjs @@ -40,6 +40,7 @@ export default class Builder { this.filesWatcher = null this.customFilesWatcher = null this.spinner = createSpinner() + this.spinner.enabled = !this.options.test // Mute stats on dev this.webpackStats = this.options.dev ? false : this.options.build.stats diff --git a/lib/builder/generator.mjs b/lib/builder/generator.mjs index 7e129cb750..3e3176f8c9 100644 --- a/lib/builder/generator.mjs +++ b/lib/builder/generator.mjs @@ -21,6 +21,7 @@ export default class Generator { ) this.spinner = createSpinner() + this.spinner.enabled = !this.options.test } async generate({ build = true, init = true } = {}) { diff --git a/lib/builder/webpack/base.config.mjs b/lib/builder/webpack/base.config.mjs index 77b3eee894..dcc91f189d 100644 --- a/lib/builder/webpack/base.config.mjs +++ b/lib/builder/webpack/base.config.mjs @@ -126,14 +126,16 @@ export default function webpackBaseConfig({ name, isServer }) { } // Build progress indicator - if (this.options.build.profile) { - config.plugins.push(new webpack.ProgressPlugin({ profile: true })) - } else { - config.plugins.push(new ProgressPlugin({ - spinner: this.spinner, - name: isServer ? 'server' : 'client', - color: isServer ? 'green' : 'darkgreen' - })) + if (!this.options.test) { + if (this.options.build.profile) { + config.plugins.push(new webpack.ProgressPlugin({ profile: true })) + } else { + config.plugins.push(new ProgressPlugin({ + spinner: this.spinner, + name: isServer ? 'server' : 'client', + color: isServer ? 'green' : 'darkgreen' + })) + } } // Add timefix-plugin before others plugins diff --git a/lib/builder/webpack/client.config.mjs b/lib/builder/webpack/client.config.mjs index 1d7a8077e1..75f546b356 100644 --- a/lib/builder/webpack/client.config.mjs +++ b/lib/builder/webpack/client.config.mjs @@ -86,9 +86,11 @@ export default function webpackClientConfig() { this.options.build.stats !== 'errors-only' // Add friendly error plugin - config.plugins.push( - new FriendlyErrorsWebpackPlugin({ clearConsole: shouldClearConsole }) - ) + if (!this.options.test) { + config.plugins.push( + new FriendlyErrorsWebpackPlugin({ clearConsole: shouldClearConsole }) + ) + } // Optimization config.optimization.splitChunks = { @@ -182,7 +184,7 @@ export default function webpackClientConfig() { } // https://github.com/webpack-contrib/webpack-stylish - if (!this.options.dev) { + if (!this.options.dev && !this.options.test) { config.plugins.push(new StylishPlugin()) } diff --git a/lib/common/nuxt.config.js b/lib/common/nuxt.config.js index db90aad66c..66fb24f63b 100644 --- a/lib/common/nuxt.config.js +++ b/lib/common/nuxt.config.js @@ -4,6 +4,7 @@ export default { mode: 'universal', dev: process.env.NODE_ENV !== 'production', debug: undefined, // Will be equal to dev if not provided + test: process.env.NODE_ENV === 'test', buildDir: '.nuxt', cacheDir: '.cache', nuxtDir: path.resolve(__dirname, '../..'),