hide fancy errors during test

This commit is contained in:
Pooya Parsa 2018-03-18 12:21:56 +03:30
parent 42a23f98d1
commit 1ee08ad101
5 changed files with 19 additions and 12 deletions

View File

@ -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

View File

@ -21,6 +21,7 @@ export default class Generator {
)
this.spinner = createSpinner()
this.spinner.enabled = !this.options.test
}
async generate({ build = true, init = true } = {}) {

View File

@ -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

View File

@ -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())
}

View File

@ -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, '../..'),