refactor: options.test from env CI or test

This commit is contained in:
Clark Du 2018-08-10 17:37:20 +01:00
parent 11bd31e788
commit c4792d247b
7 changed files with 6 additions and 10 deletions

View File

@ -110,7 +110,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
}
// Add friendly error plugin
if (this.options.dev) {
if (this.options.dev && !this.options.test) {
config.plugins.push(
new FriendlyErrorsWebpackPlugin({
clearConsole: true,

View File

@ -10,6 +10,7 @@ export default {
// Information about running environment
dev: Boolean(env.dev),
debug: undefined, // = dev
test: Boolean(env.ci || env.test),
// Mode
mode: 'universal',

View File

@ -190,7 +190,7 @@ Options.from = function (_options) {
options.build.optimization.splitChunks.name = true
}
if (options.build.stats === 'none') {
if (options.build.stats === 'none' || options.test === true) {
options.build.stats = false
}

View File

@ -13,7 +13,6 @@ let page = null
// Init nuxt.js and create server listening on localhost:4003
test.serial('Init Nuxt.js', async (t) => {
const options = {
test: true,
rootDir: resolve(__dirname, 'fixtures/basic'),
buildDir: '.nuxt-csr',
dev: true,

View File

@ -9,7 +9,6 @@ let transpile = null
describe('basic dev', () => {
beforeAll(async () => {
const config = loadFixture('basic', {
test: true,
dev: true,
debug: true,
buildDir: '.nuxt-dev',

View File

@ -7,7 +7,7 @@ describe('nuxt', () => {
})
test('Nuxt.js Instance', async () => {
const config = loadFixture('empty', { test: true })
const config = loadFixture('empty')
const nuxt = new Nuxt(config)
expect(typeof nuxt).toBe('object')
@ -33,7 +33,7 @@ describe('nuxt', () => {
})
test('Build with default page when no pages/ directory', async () => {
const nuxt = new Nuxt({ test: true })
const nuxt = new Nuxt()
new Builder(nuxt).build()
const port = await getPort()
await nuxt.listen(port, 'localhost')
@ -46,7 +46,6 @@ describe('nuxt', () => {
test('Fail to build when specified plugin isn\'t found', () => {
const nuxt = new Nuxt({
test: true,
dev: false,
rootDir: resolve(__dirname, '..', 'fixtures', 'missing-plugin')
})

View File

@ -2,9 +2,7 @@ import { loadFixture, Nuxt, Builder } from './index'
export const buildFixture = function buildFixture(fixture) {
test(`Build ${fixture}`, async () => {
const config = loadFixture(fixture, {
test: true
})
const config = loadFixture(fixture)
const nuxt = new Nuxt(config)
const buildDone = jest.fn()
nuxt.hook('build:done', buildDone)