diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 21a55ae45c..1fcb834c59 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -45,10 +45,12 @@ export default class Builder extends Tapable { async build () { // Avoid calling build() method multiple times when dev:true + /* istanbul ignore if */ if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) { return this } // If building + /* istanbul ignore if */ if (this._buildStatus === STATUS.BUILDING) { return new Promise((resolve) => { setTimeout(() => { @@ -287,6 +289,7 @@ export default class Builder extends Tapable { // Run after each compile this.compiler.plugin('done', stats => { // Don't reload failed builds + /* istanbul ignore if */ if (stats.hasErrors() || stats.hasWarnings()) { return } @@ -311,6 +314,7 @@ export default class Builder extends Tapable { } else { // Build and watch for changes compiler.watch(this.options.watchers.webpack, (err) => { + /* istanbul ignore if */ if (err) { return reject(err) } @@ -326,6 +330,7 @@ export default class Builder extends Tapable { if (err) return console.error(err) // eslint-disable-line no-console // Show build stats for production console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console + /* istanbul ignore if */ if (stats.hasErrors()) { return reject(new Error('Webpack build exited with errors')) } diff --git a/lib/builder/generator.js b/lib/builder/generator.js index 2589134043..081c624f6d 100644 --- a/lib/builder/generator.js +++ b/lib/builder/generator.js @@ -41,6 +41,7 @@ export default class Generator extends Tapable { debug('Destination folder cleaned') // Copy static and built files + /* istanbul ignore if */ if (fs.existsSync(srcStaticPath)) { await copy(srcStaticPath, distPath) } diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index ce1440d8fa..a5c0402376 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -18,6 +18,7 @@ import { styleLoader, extractStyles } from './helpers' export default function webpackBaseConfig ({ isClient, isServer }) { const nodeModulesDir = join(__dirname, '..', 'node_modules') + /* istanbul ignore if */ if (!Array.isArray(this.options.build.postcss)) { this.options.build.postcss = [ autoprefixer({ diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index da7e553555..c32348747c 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -57,6 +57,7 @@ export default function webpackClientConfig () { }) // Webpack common plugins + /* istanbul ignore if */ if (!Array.isArray(config.plugins)) { config.plugins = [] } diff --git a/lib/common/utils.js b/lib/common/utils.js index fcfe7eba4b..dae71bd461 100644 --- a/lib/common/utils.js +++ b/lib/common/utils.js @@ -105,6 +105,7 @@ export function r () { export function flatRoutes (router, path = '', routes = []) { router.forEach((r) => { if (!r.path.includes(':') && !r.path.includes('*')) { + /* istanbul ignore if */ if (r.children) { flatRoutes(r.children, path + r.path + '/', routes) } else { diff --git a/lib/core/module.js b/lib/core/module.js index fdd2746764..e18380ff0f 100755 --- a/lib/core/module.js +++ b/lib/core/module.js @@ -38,6 +38,7 @@ export default class ModuleContainer extends Tapable { const srcPath = path.parse(src) /* istanbul ignore if */ if (!src || typeof src !== 'string' || !fs.existsSync(src)) { + /* istanbul ignore next */ debug('[nuxt] invalid template', template) return } diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index a6f9ffd510..4b05742a0c 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -38,7 +38,7 @@ export default class Nuxt extends Tapable { return this } - errorHandler () { + errorHandler /* istanbul ignore next */ () { // Silent if (this.options.errorHandler === false) { return diff --git a/lib/core/options.js b/lib/core/options.js index 498ec8c30d..90e990b3eb 100755 --- a/lib/core/options.js +++ b/lib/core/options.js @@ -36,6 +36,7 @@ export default function Options (_options) { } // Ignore publicPath on dev + /* istanbul ignore if */ if (options.dev && isUrl(options.build.publicPath)) { options.build.publicPath = defaultOptions.build.publicPath } diff --git a/lib/core/renderer.js b/lib/core/renderer.js index b688b25b99..a30ebb35b1 100644 --- a/lib/core/renderer.js +++ b/lib/core/renderer.js @@ -1,17 +1,16 @@ -import ansiHTML from 'ansi-html' -import serialize from 'serialize-javascript' -import generateETag from 'etag' -import fresh from 'fresh' -import Tapable from 'tappable' -import pify from 'pify' -import serveStatic from 'serve-static' -import compression from 'compression' -import _ from 'lodash' -import { resolve, join } from 'path' -import fs from 'fs-extra' -import { createBundleRenderer } from 'vue-server-renderer' -import { getContext, setAnsiColors, encodeHtml } from 'utils' -import Debug from 'debug' +import ansiHTML from "ansi-html"; +import serialize from "serialize-javascript"; +import generateETag from "etag"; +import fresh from "fresh"; +import Tapable from "tappable"; +import pify from "pify"; +import compression from "compression"; +import _ from "lodash"; +import { join, resolve } from "path"; +import fs from "fs-extra"; +import { createBundleRenderer } from "vue-server-renderer"; +import { encodeHtml, getContext, setAnsiColors } from "utils"; +import Debug from "debug"; const debug = Debug('nuxt:render') debug.color = 4 // Force blue color @@ -46,6 +45,7 @@ export default class Renderer extends Tapable { } // Initialize + /* istanbul ignore if */ if (nuxt.initialized) { // If nuxt already initialized this._ready = this.ready().catch(this.nuxt.errorHandler) @@ -59,6 +59,7 @@ export default class Renderer extends Tapable { } async ready () { + /* istanbul ignore if */ if (this._ready) { return this._ready } @@ -122,6 +123,7 @@ export default class Renderer extends Tapable { } this.resources[rawKey] = rawData data = transform(rawData) + /* istanbul ignore if */ if (!data) { return // Invalid data ? } @@ -337,10 +339,9 @@ export default class Renderer extends Tapable { const { window } = await jsdom.JSDOM.fromURL(url, options) // If Nuxt could not be loaded (error from the server-side) const nuxtExists = window.document.body.innerHTML.includes('window.__NUXT__') + /* istanbul ignore if */ if (!nuxtExists) { - /* istanbul ignore next */ let error = new Error('Could not load the nuxt app') - /* istanbul ignore next */ error.body = window.document.body.innerHTML throw error } diff --git a/lib/core/server.js b/lib/core/server.js index 619f4c879f..2d855d073f 100644 --- a/lib/core/server.js +++ b/lib/core/server.js @@ -9,6 +9,7 @@ class Server { this.options = nuxt.options // Initialize + /* istanbul ignore if */ if (nuxt.initialized) { // If nuxt already initialized this._ready = this.ready().catch(this.nuxt.errorHandler) @@ -22,6 +23,7 @@ class Server { } async ready () { + /* istanbul ignore if */ if (this._ready) { return this._ready }