mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(test): remove local paths
This commit is contained in:
parent
bd1ae0b9df
commit
d02eb2f958
@ -4,8 +4,8 @@ exports[`config: options should return default nuxt config 1`] = `
|
|||||||
Object {
|
Object {
|
||||||
"ErrorPage": null,
|
"ErrorPage": null,
|
||||||
"__normalized__": true,
|
"__normalized__": true,
|
||||||
"_nuxtConfigFile": "/mnt/c/Users/CDu/projects/github/nuxt.js/nuxt.config.js",
|
"_nuxtConfigFile": "/var/nuxt/test/nuxt.config.js",
|
||||||
"appTemplatePath": "/mnt/c/Users/CDu/projects/github/nuxt.js/.nuxt/views/app.template.html",
|
"appTemplatePath": "/var/nuxt/test/.nuxt/views/app.template.html",
|
||||||
"build": Object {
|
"build": Object {
|
||||||
"_publicPath": "/_nuxt/",
|
"_publicPath": "/_nuxt/",
|
||||||
"analyze": false,
|
"analyze": false,
|
||||||
@ -134,7 +134,7 @@ Object {
|
|||||||
"useForkTsChecker": false,
|
"useForkTsChecker": false,
|
||||||
"watch": Array [],
|
"watch": Array [],
|
||||||
},
|
},
|
||||||
"buildDir": "/mnt/c/Users/CDu/projects/github/nuxt.js/.nuxt",
|
"buildDir": "/var/nuxt/test/.nuxt",
|
||||||
"cli": Object {
|
"cli": Object {
|
||||||
"badgeMessages": Array [],
|
"badgeMessages": Array [],
|
||||||
},
|
},
|
||||||
@ -158,7 +158,7 @@ Object {
|
|||||||
],
|
],
|
||||||
"generate": Object {
|
"generate": Object {
|
||||||
"concurrency": 500,
|
"concurrency": 500,
|
||||||
"dir": "/mnt/c/Users/CDu/projects/github/nuxt.js/dist",
|
"dir": "/var/nuxt/test/dist",
|
||||||
"fallback": "200.html",
|
"fallback": "200.html",
|
||||||
"interval": 0,
|
"interval": 0,
|
||||||
"routes": Array [],
|
"routes": Array [],
|
||||||
@ -240,19 +240,6 @@ Object {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"modules": Array [],
|
"modules": Array [],
|
||||||
"modulesDir": Array [
|
|
||||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/packages/config/test/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/packages/config/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/packages/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/projects/github/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/projects/node_modules",
|
|
||||||
"/mnt/c/Users/CDu/node_modules",
|
|
||||||
"/mnt/c/Users/node_modules",
|
|
||||||
"/mnt/c/node_modules",
|
|
||||||
"/mnt/node_modules",
|
|
||||||
"/node_modules",
|
|
||||||
],
|
|
||||||
"plugins": Array [],
|
"plugins": Array [],
|
||||||
"render": Object {
|
"render": Object {
|
||||||
"bundleRenderer": Object {
|
"bundleRenderer": Object {
|
||||||
@ -292,7 +279,7 @@ Object {
|
|||||||
"prefix": true,
|
"prefix": true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"rootDir": "/mnt/c/Users/CDu/projects/github/nuxt.js",
|
"rootDir": "/var/nuxt/test",
|
||||||
"router": Object {
|
"router": Object {
|
||||||
"base": "/",
|
"base": "/",
|
||||||
"extendRoutes": null,
|
"extendRoutes": null,
|
||||||
@ -316,7 +303,7 @@ Object {
|
|||||||
"socket": undefined,
|
"socket": undefined,
|
||||||
},
|
},
|
||||||
"serverMiddleware": Array [],
|
"serverMiddleware": Array [],
|
||||||
"srcDir": "/mnt/c/Users/CDu/projects/github/nuxt.js",
|
"srcDir": "/var/nuxt/test",
|
||||||
"styleExtensions": Array [
|
"styleExtensions": Array [
|
||||||
"css",
|
"css",
|
||||||
"pcss",
|
"pcss",
|
||||||
@ -343,7 +330,7 @@ Object {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"watch": Array [
|
"watch": Array [
|
||||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/nuxt.config.js",
|
"/var/nuxt/test/nuxt.config.js",
|
||||||
],
|
],
|
||||||
"watchers": Object {
|
"watchers": Object {
|
||||||
"chokidar": Object {
|
"chokidar": Object {
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
import { getDefaultNuxtConfig } from '../../src/config'
|
import { getDefaultNuxtConfig } from '../../src/config'
|
||||||
|
|
||||||
|
jest.mock('std-env', () => ({
|
||||||
|
browser: false,
|
||||||
|
test: 'test',
|
||||||
|
dev: false,
|
||||||
|
production: true,
|
||||||
|
debug: false,
|
||||||
|
ci: true,
|
||||||
|
windows: false,
|
||||||
|
darwin: false,
|
||||||
|
linux: true
|
||||||
|
}))
|
||||||
|
|
||||||
describe('config', () => {
|
describe('config', () => {
|
||||||
test('should return default nuxt configurations', () => {
|
test('should return default nuxt configurations', () => {
|
||||||
expect(getDefaultNuxtConfig()).toMatchSnapshot()
|
expect(getDefaultNuxtConfig()).toMatchSnapshot()
|
||||||
|
@ -1,23 +1,41 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import consola from 'consola'
|
import consola from 'consola'
|
||||||
import { getNuxtConfig } from '../src/options'
|
import * as options from '../src/options'
|
||||||
|
|
||||||
|
jest.mock('std-env', () => ({
|
||||||
|
browser: false,
|
||||||
|
test: 'test',
|
||||||
|
dev: false,
|
||||||
|
production: true,
|
||||||
|
debug: false,
|
||||||
|
ci: true,
|
||||||
|
windows: false,
|
||||||
|
darwin: false,
|
||||||
|
linux: true
|
||||||
|
}))
|
||||||
|
|
||||||
describe('config: options', () => {
|
describe('config: options', () => {
|
||||||
test('should return default nuxt config', () => {
|
test('should return default nuxt config', () => {
|
||||||
expect(getNuxtConfig({})).toMatchSnapshot()
|
jest.spyOn(process, 'cwd').mockReturnValue('/var/nuxt/test')
|
||||||
|
|
||||||
|
const config = options.getNuxtConfig({})
|
||||||
|
delete config.modulesDir
|
||||||
|
expect(config).toMatchSnapshot()
|
||||||
|
|
||||||
|
process.cwd.mockRestore()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should prevent duplicate calls with same options', () => {
|
test('should prevent duplicate calls with same options', () => {
|
||||||
const options = {}
|
const options = {}
|
||||||
const firstConfig = getNuxtConfig(options)
|
const firstConfig = options.getNuxtConfig(options)
|
||||||
const secondConfig = getNuxtConfig(firstConfig)
|
const secondConfig = options.getNuxtConfig(firstConfig)
|
||||||
|
|
||||||
expect(firstConfig).toBe(secondConfig)
|
expect(firstConfig).toBe(secondConfig)
|
||||||
expect(firstConfig.__normalized__).toBe(true)
|
expect(firstConfig.__normalized__).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should return default loading when loading is true', () => {
|
test('should return default loading when loading is true', () => {
|
||||||
const { loading } = getNuxtConfig({ loading: true })
|
const { loading } = options.getNuxtConfig({ loading: true })
|
||||||
expect(loading).toEqual({
|
expect(loading).toEqual({
|
||||||
color: 'black',
|
color: 'black',
|
||||||
failedColor: 'red',
|
failedColor: 'red',
|
||||||
@ -31,7 +49,7 @@ describe('config: options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should transform transition/layoutTransition to name', () => {
|
test('should transform transition/layoutTransition to name', () => {
|
||||||
const { transition, layoutTransition } = getNuxtConfig({
|
const { transition, layoutTransition } = options.getNuxtConfig({
|
||||||
transition: 'test-tran',
|
transition: 'test-tran',
|
||||||
layoutTransition: 'test-layout-tran'
|
layoutTransition: 'test-layout-tran'
|
||||||
})
|
})
|
||||||
@ -40,22 +58,22 @@ describe('config: options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should transform extensions to array', () => {
|
test('should transform extensions to array', () => {
|
||||||
const { extensions } = getNuxtConfig({ extensions: 'ext' })
|
const { extensions } = options.getNuxtConfig({ extensions: 'ext' })
|
||||||
expect(extensions).toEqual(['js', 'mjs', 'ts', 'ext'])
|
expect(extensions).toEqual(['js', 'mjs', 'ts', 'ext'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should support custom global name', () => {
|
test('should support custom global name', () => {
|
||||||
const { globalName } = getNuxtConfig({ globalName: 'globalNuxt' })
|
const { globalName } = options.getNuxtConfig({ globalName: 'globalNuxt' })
|
||||||
expect(globalName).toEqual('globalnuxt')
|
expect(globalName).toEqual('globalnuxt')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should detect store dir', () => {
|
test('should detect store dir', () => {
|
||||||
const { store } = getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
const { store } = options.getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
||||||
expect(store).toEqual(true)
|
expect(store).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should enable csp', () => {
|
test('should enable csp', () => {
|
||||||
const { render: { csp } } = getNuxtConfig({ render: { csp: { allowedSources: true, test: true } } })
|
const { render: { csp } } = options.getNuxtConfig({ render: { csp: { allowedSources: true, test: true } } })
|
||||||
expect(csp).toEqual({
|
expect(csp).toEqual({
|
||||||
hashAlgorithm: 'sha256',
|
hashAlgorithm: 'sha256',
|
||||||
allowedSources: true,
|
allowedSources: true,
|
||||||
@ -66,39 +84,39 @@ describe('config: options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should check unknown mode', () => {
|
test('should check unknown mode', () => {
|
||||||
const { build, render } = getNuxtConfig({ mode: 'test' })
|
const { build, render } = options.getNuxtConfig({ mode: 'test' })
|
||||||
expect(consola.warn).toHaveBeenCalledWith('Unknown mode: test. Falling back to universal')
|
expect(consola.warn).toHaveBeenCalledWith('Unknown mode: test. Falling back to universal')
|
||||||
expect(build.ssr).toEqual(true)
|
expect(build.ssr).toEqual(true)
|
||||||
expect(render.ssr).toEqual(true)
|
expect(render.ssr).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should return 404.html as default generate.fallback', () => {
|
test('should return 404.html as default generate.fallback', () => {
|
||||||
const { generate: { fallback } } = getNuxtConfig({ generate: { fallback: true } })
|
const { generate: { fallback } } = options.getNuxtConfig({ generate: { fallback: true } })
|
||||||
expect(fallback).toEqual('404.html')
|
expect(fallback).toEqual('404.html')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('config: router dir', () => {
|
describe('config: router dir', () => {
|
||||||
test('should transform middleware to array', () => {
|
test('should transform middleware to array', () => {
|
||||||
const { router: { middleware } } = getNuxtConfig({ router: { middleware: 'midd' } })
|
const { router: { middleware } } = options.getNuxtConfig({ router: { middleware: 'midd' } })
|
||||||
expect(middleware).toEqual(['midd'])
|
expect(middleware).toEqual(['midd'])
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should set _routerBaseSpecified when base is specified', () => {
|
test('should set _routerBaseSpecified when base is specified', () => {
|
||||||
const { _routerBaseSpecified } = getNuxtConfig({ router: { base: '/test' } })
|
const { _routerBaseSpecified } = options.getNuxtConfig({ router: { base: '/test' } })
|
||||||
expect(_routerBaseSpecified).toEqual(true)
|
expect(_routerBaseSpecified).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('config: options dir', () => {
|
describe('config: options dir', () => {
|
||||||
test('should support custom root dir', () => {
|
test('should support custom root dir', () => {
|
||||||
const { rootDir } = getNuxtConfig({
|
const { rootDir } = options.getNuxtConfig({
|
||||||
rootDir: 'root'
|
rootDir: 'root'
|
||||||
})
|
})
|
||||||
expect(rootDir).toEqual(path.resolve('root'))
|
expect(rootDir).toEqual(path.resolve('root'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should support custom src dir', () => {
|
test('should support custom src dir', () => {
|
||||||
const { srcDir } = getNuxtConfig({
|
const { srcDir } = options.getNuxtConfig({
|
||||||
rootDir: 'root',
|
rootDir: 'root',
|
||||||
srcDir: 'src'
|
srcDir: 'src'
|
||||||
})
|
})
|
||||||
@ -106,7 +124,7 @@ describe('config: options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should support custom generate dir', () => {
|
test('should support custom generate dir', () => {
|
||||||
const { generate: { dir } } = getNuxtConfig({
|
const { generate: { dir } } = options.getNuxtConfig({
|
||||||
rootDir: 'root',
|
rootDir: 'root',
|
||||||
generate: { dir: 'generate' }
|
generate: { dir: 'generate' }
|
||||||
})
|
})
|
||||||
@ -116,41 +134,41 @@ describe('config: options', () => {
|
|||||||
|
|
||||||
describe('config: options template', () => {
|
describe('config: options template', () => {
|
||||||
test('should use default appTemplatePath', () => {
|
test('should use default appTemplatePath', () => {
|
||||||
const { appTemplatePath } = getNuxtConfig({})
|
const { appTemplatePath } = options.getNuxtConfig({})
|
||||||
expect(appTemplatePath).toEqual(path.resolve('.nuxt', 'views', 'app.template.html'))
|
expect(appTemplatePath).toEqual(path.resolve('.nuxt', 'views', 'app.template.html'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should use custom appTemplatePath', () => {
|
test('should use custom appTemplatePath', () => {
|
||||||
const { appTemplatePath } = getNuxtConfig({ appTemplatePath: 'templates' })
|
const { appTemplatePath } = options.getNuxtConfig({ appTemplatePath: 'templates' })
|
||||||
expect(appTemplatePath).toEqual(path.resolve('templates'))
|
expect(appTemplatePath).toEqual(path.resolve('templates'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should use custom app.html', () => {
|
test('should use custom app.html', () => {
|
||||||
const { appTemplatePath } = getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
const { appTemplatePath } = options.getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
||||||
expect(appTemplatePath).toEqual(path.resolve(__dirname, 'fixtures', 'app.html'))
|
expect(appTemplatePath).toEqual(path.resolve(__dirname, 'fixtures', 'app.html'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('config: options publicPath', () => {
|
describe('config: options publicPath', () => {
|
||||||
test('should fallback to default when publicPath is falsy', () => {
|
test('should fallback to default when publicPath is falsy', () => {
|
||||||
const { build: { publicPath } } = getNuxtConfig({ build: { publicPath: false } })
|
const { build: { publicPath } } = options.getNuxtConfig({ build: { publicPath: false } })
|
||||||
expect(publicPath).toEqual('/_nuxt/')
|
expect(publicPath).toEqual('/_nuxt/')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should append slash in publicPath', () => {
|
test('should append slash in publicPath', () => {
|
||||||
const { build: { publicPath } } = getNuxtConfig({ build: { publicPath: '/nuxt_public' } })
|
const { build: { publicPath } } = options.getNuxtConfig({ build: { publicPath: '/nuxt_public' } })
|
||||||
expect(publicPath).toEqual('/nuxt_public/')
|
expect(publicPath).toEqual('/nuxt_public/')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should ignore url publicPath in dev', () => {
|
test('should ignore url publicPath in dev', () => {
|
||||||
const { build: { publicPath } } = getNuxtConfig({ dev: true, build: { publicPath: 'http://nuxt_public' } })
|
const { build: { publicPath } } = options.getNuxtConfig({ dev: true, build: { publicPath: 'http://nuxt_public' } })
|
||||||
expect(publicPath).toEqual('/_nuxt/')
|
expect(publicPath).toEqual('/_nuxt/')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('config: options babel', () => {
|
describe('config: options babel', () => {
|
||||||
test('should replace and deprecate @nuxtjs/babel-preset-app', () => {
|
test('should replace and deprecate @nuxtjs/babel-preset-app', () => {
|
||||||
const { build: { babel } } = getNuxtConfig({
|
const { build: { babel } } = options.getNuxtConfig({
|
||||||
build: { babel: { presets: ['@nuxtjs/babel-preset-app'] } }
|
build: { babel: { presets: ['@nuxtjs/babel-preset-app'] } }
|
||||||
})
|
})
|
||||||
expect(consola.warn).toHaveBeenCalledWith('@nuxtjs/babel-preset-app has been deprecated, please use @nuxt/babel-preset-app.')
|
expect(consola.warn).toHaveBeenCalledWith('@nuxtjs/babel-preset-app has been deprecated, please use @nuxt/babel-preset-app.')
|
||||||
@ -162,7 +180,7 @@ describe('config: options', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should support options in babel presets', () => {
|
test('should support options in babel presets', () => {
|
||||||
const { build: { babel } } = getNuxtConfig({
|
const { build: { babel } } = options.getNuxtConfig({
|
||||||
build: { babel: { presets: [['@nuxt/babel-preset-app', { test: true }]] } }
|
build: { babel: { presets: [['@nuxt/babel-preset-app', { test: true }]] } }
|
||||||
})
|
})
|
||||||
expect(babel).toEqual({
|
expect(babel).toEqual({
|
||||||
@ -175,17 +193,17 @@ describe('config: options', () => {
|
|||||||
|
|
||||||
describe('config: options deprecated', () => {
|
describe('config: options deprecated', () => {
|
||||||
test('should deprecate render.gzip', () => {
|
test('should deprecate render.gzip', () => {
|
||||||
getNuxtConfig({ render: { gzip: true } })
|
options.getNuxtConfig({ render: { gzip: true } })
|
||||||
expect(consola.warn).toHaveBeenCalledWith('render.gzip is deprecated and will be removed in a future version! Please switch to render.compressor')
|
expect(consola.warn).toHaveBeenCalledWith('render.gzip is deprecated and will be removed in a future version! Please switch to render.compressor')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should deprecate build.vendor', () => {
|
test('should deprecate build.vendor', () => {
|
||||||
getNuxtConfig({ build: { vendor: ['lodash'] } })
|
options.getNuxtConfig({ build: { vendor: ['lodash'] } })
|
||||||
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization')
|
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should deprecate build.extractCSS.allChunks', () => {
|
test('should deprecate build.extractCSS.allChunks', () => {
|
||||||
getNuxtConfig({ build: { extractCSS: { allChunks: true } } })
|
options.getNuxtConfig({ build: { extractCSS: { allChunks: true } } })
|
||||||
expect(consola.warn).toHaveBeenCalledWith('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
|
expect(consola.warn).toHaveBeenCalledWith('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user