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 // Add friendly error plugin
if (this.options.dev) { if (this.options.dev && !this.options.test) {
config.plugins.push( config.plugins.push(
new FriendlyErrorsWebpackPlugin({ new FriendlyErrorsWebpackPlugin({
clearConsole: true, clearConsole: true,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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