mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
test: add unit tests for @nuxt/config
This commit is contained in:
parent
1b84fa84e1
commit
bd1ae0b9df
@ -1,4 +1,4 @@
|
||||
export default ({ env }) => ({
|
||||
export default ({ env = {} } = {}) => ({
|
||||
https: false,
|
||||
port: env.NUXT_PORT ||
|
||||
env.PORT ||
|
||||
|
358
packages/config/test/__snapshots__/options.test.js.snap
Normal file
358
packages/config/test/__snapshots__/options.test.js.snap
Normal file
@ -0,0 +1,358 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`config: options should return default nuxt config 1`] = `
|
||||
Object {
|
||||
"ErrorPage": null,
|
||||
"__normalized__": true,
|
||||
"_nuxtConfigFile": "/mnt/c/Users/CDu/projects/github/nuxt.js/nuxt.config.js",
|
||||
"appTemplatePath": "/mnt/c/Users/CDu/projects/github/nuxt.js/.nuxt/views/app.template.html",
|
||||
"build": Object {
|
||||
"_publicPath": "/_nuxt/",
|
||||
"analyze": false,
|
||||
"babel": Object {
|
||||
"babelrc": false,
|
||||
"cacheDirectory": false,
|
||||
},
|
||||
"cache": false,
|
||||
"crossorigin": undefined,
|
||||
"cssSourceMap": false,
|
||||
"devMiddleware": Object {},
|
||||
"extractCSS": false,
|
||||
"filenames": Object {
|
||||
"app": [Function],
|
||||
"chunk": [Function],
|
||||
"css": [Function],
|
||||
"font": [Function],
|
||||
"img": [Function],
|
||||
"video": [Function],
|
||||
},
|
||||
"friendlyErrors": true,
|
||||
"hardSource": false,
|
||||
"hotMiddleware": Object {},
|
||||
"html": Object {
|
||||
"minify": Object {
|
||||
"collapseBooleanAttributes": true,
|
||||
"decodeEntities": true,
|
||||
"minifyCSS": true,
|
||||
"minifyJS": true,
|
||||
"processConditionalComments": true,
|
||||
"removeEmptyAttributes": true,
|
||||
"removeRedundantAttributes": true,
|
||||
"trimCustomFragments": true,
|
||||
"useShortDoctype": true,
|
||||
},
|
||||
},
|
||||
"loaders": Object {
|
||||
"css": Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
"sourceMap": false,
|
||||
},
|
||||
"file": Object {},
|
||||
"fontUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"imgUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"less": Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
"pugPlain": Object {},
|
||||
"sass": Object {
|
||||
"indentedSyntax": true,
|
||||
"sourceMap": false,
|
||||
},
|
||||
"scss": Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
"stylus": Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
"ts": Object {
|
||||
"appendTsSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"tsx": Object {
|
||||
"appendTsxSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"vue": Object {
|
||||
"productionMode": true,
|
||||
"transformAssetUrls": Object {
|
||||
"embed": "src",
|
||||
"object": "src",
|
||||
"source": "src",
|
||||
"video": "src",
|
||||
},
|
||||
},
|
||||
"vueStyle": Object {
|
||||
"sourceMap": false,
|
||||
},
|
||||
},
|
||||
"optimization": Object {
|
||||
"minimize": true,
|
||||
"minimizer": undefined,
|
||||
"runtimeChunk": "single",
|
||||
"splitChunks": Object {
|
||||
"automaticNameDelimiter": ".",
|
||||
"cacheGroups": Object {},
|
||||
"chunks": "all",
|
||||
"name": undefined,
|
||||
},
|
||||
},
|
||||
"optimizeCSS": false,
|
||||
"parallel": false,
|
||||
"plugins": Array [],
|
||||
"postcss": Object {
|
||||
"preset": Object {
|
||||
"stage": 2,
|
||||
},
|
||||
},
|
||||
"profile": false,
|
||||
"publicPath": "/_nuxt/",
|
||||
"quiet": true,
|
||||
"splitChunks": Object {
|
||||
"commons": true,
|
||||
"layouts": false,
|
||||
"pages": true,
|
||||
},
|
||||
"ssr": true,
|
||||
"standalone": false,
|
||||
"stats": false,
|
||||
"styleResources": Object {},
|
||||
"template": undefined,
|
||||
"templates": Array [],
|
||||
"terser": Object {},
|
||||
"transpile": Array [],
|
||||
"useForkTsChecker": false,
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": "/mnt/c/Users/CDu/projects/github/nuxt.js/.nuxt",
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": false,
|
||||
"dev": false,
|
||||
"dir": Object {
|
||||
"assets": "assets",
|
||||
"layouts": "layouts",
|
||||
"middleware": "middleware",
|
||||
"pages": "pages",
|
||||
"static": "static",
|
||||
"store": "store",
|
||||
},
|
||||
"editor": undefined,
|
||||
"env": Object {},
|
||||
"extensions": Array [
|
||||
"js",
|
||||
"mjs",
|
||||
"ts",
|
||||
],
|
||||
"generate": Object {
|
||||
"concurrency": 500,
|
||||
"dir": "/mnt/c/Users/CDu/projects/github/nuxt.js/dist",
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"routes": Array [],
|
||||
"subFolders": true,
|
||||
},
|
||||
"globalName": "nuxt",
|
||||
"globals": Object {
|
||||
"context": [Function],
|
||||
"id": [Function],
|
||||
"loadedCallback": [Function],
|
||||
"nuxt": [Function],
|
||||
"pluginPrefix": [Function],
|
||||
"readyCallback": [Function],
|
||||
},
|
||||
"head": Object {
|
||||
"link": Array [],
|
||||
"meta": Array [],
|
||||
"script": Array [],
|
||||
"style": Array [],
|
||||
},
|
||||
"hooks": null,
|
||||
"ignore": Array [
|
||||
"**/*.test.*",
|
||||
"**/*.spec.*",
|
||||
"**/-*.*",
|
||||
],
|
||||
"ignorePrefix": "-",
|
||||
"layoutTransition": Object {
|
||||
"mode": "out-in",
|
||||
"name": "layout",
|
||||
},
|
||||
"layouts": Object {},
|
||||
"loading": Object {
|
||||
"color": "black",
|
||||
"continuous": false,
|
||||
"css": true,
|
||||
"duration": 5000,
|
||||
"failedColor": "red",
|
||||
"height": "2px",
|
||||
"rtl": false,
|
||||
"throttle": 200,
|
||||
},
|
||||
"loadingIndicator": Object {
|
||||
"background": "white",
|
||||
"color": "black",
|
||||
"color2": "#F5F5F5",
|
||||
"dev": false,
|
||||
"loading": "Loading...",
|
||||
"name": "default",
|
||||
},
|
||||
"messages": Object {
|
||||
"back_to_home": "Back to the home page",
|
||||
"client_error": "Error",
|
||||
"client_error_details": "An error occurred while rendering the page. Check developer tools console for details.",
|
||||
"error_404": "This page could not be found",
|
||||
"loading": "Loading...",
|
||||
"nuxtjs": "Nuxt.js",
|
||||
"server_error": "Server error",
|
||||
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
||||
},
|
||||
"mode": "universal",
|
||||
"modern": undefined,
|
||||
"modes": Object {
|
||||
"spa": Object {
|
||||
"build": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
},
|
||||
"universal": Object {
|
||||
"build": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"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 [],
|
||||
"render": Object {
|
||||
"bundleRenderer": Object {
|
||||
"runInNewContext": false,
|
||||
"shouldPrefetch": [Function],
|
||||
"shouldPreload": [Function],
|
||||
},
|
||||
"compressor": Object {
|
||||
"threshold": 0,
|
||||
},
|
||||
"csp": false,
|
||||
"dist": Object {
|
||||
"index": false,
|
||||
"maxAge": "1y",
|
||||
},
|
||||
"etag": Object {
|
||||
"weak": false,
|
||||
},
|
||||
"fallback": Object {
|
||||
"dist": Object {},
|
||||
"static": Object {
|
||||
"handlers": Object {
|
||||
".htm": false,
|
||||
".html": false,
|
||||
},
|
||||
"skipUnknown": true,
|
||||
},
|
||||
},
|
||||
"http2": Object {
|
||||
"push": false,
|
||||
"pushAssets": null,
|
||||
"shouldPush": null,
|
||||
},
|
||||
"resourceHints": true,
|
||||
"ssr": true,
|
||||
"static": Object {
|
||||
"prefix": true,
|
||||
},
|
||||
},
|
||||
"rootDir": "/mnt/c/Users/CDu/projects/github/nuxt.js",
|
||||
"router": Object {
|
||||
"base": "/",
|
||||
"extendRoutes": null,
|
||||
"fallback": false,
|
||||
"linkActiveClass": "nuxt-link-active",
|
||||
"linkExactActiveClass": "nuxt-link-exact-active",
|
||||
"linkPrefetchedClass": false,
|
||||
"middleware": Array [],
|
||||
"mode": "history",
|
||||
"parseQuery": false,
|
||||
"prefetchLinks": true,
|
||||
"routeNameSplitter": "-",
|
||||
"routes": Array [],
|
||||
"scrollBehavior": null,
|
||||
"stringifyQuery": false,
|
||||
},
|
||||
"server": Object {
|
||||
"host": "localhost",
|
||||
"https": false,
|
||||
"port": 3000,
|
||||
"socket": undefined,
|
||||
},
|
||||
"serverMiddleware": Array [],
|
||||
"srcDir": "/mnt/c/Users/CDu/projects/github/nuxt.js",
|
||||
"styleExtensions": Array [
|
||||
"css",
|
||||
"pcss",
|
||||
"postcss",
|
||||
"styl",
|
||||
"stylus",
|
||||
"scss",
|
||||
"sass",
|
||||
"less",
|
||||
],
|
||||
"test": true,
|
||||
"transition": Object {
|
||||
"appear": false,
|
||||
"appearActiveClass": "appear-active",
|
||||
"appearClass": "appear",
|
||||
"appearToClass": "appear-to",
|
||||
"mode": "out-in",
|
||||
"name": "page",
|
||||
},
|
||||
"vue": Object {
|
||||
"config": Object {
|
||||
"performance": false,
|
||||
"silent": true,
|
||||
},
|
||||
},
|
||||
"watch": Array [
|
||||
"/mnt/c/Users/CDu/projects/github/nuxt.js/nuxt.config.js",
|
||||
],
|
||||
"watchers": Object {
|
||||
"chokidar": Object {
|
||||
"ignoreInitial": true,
|
||||
},
|
||||
"rewatchOnRawEvents": Array [
|
||||
"rename",
|
||||
],
|
||||
"webpack": Object {},
|
||||
},
|
||||
}
|
||||
`;
|
645
packages/config/test/config/__snapshots__/index.test.js.snap
Normal file
645
packages/config/test/config/__snapshots__/index.test.js.snap
Normal file
@ -0,0 +1,645 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`config should return default nuxt configurations 1`] = `
|
||||
Object {
|
||||
"ErrorPage": null,
|
||||
"_nuxtConfigFile": undefined,
|
||||
"build": Object {
|
||||
"analyze": false,
|
||||
"babel": Object {
|
||||
"babelrc": false,
|
||||
"cacheDirectory": undefined,
|
||||
},
|
||||
"cache": false,
|
||||
"crossorigin": undefined,
|
||||
"cssSourceMap": undefined,
|
||||
"devMiddleware": Object {},
|
||||
"extractCSS": false,
|
||||
"filenames": Object {
|
||||
"app": [Function],
|
||||
"chunk": [Function],
|
||||
"css": [Function],
|
||||
"font": [Function],
|
||||
"img": [Function],
|
||||
"video": [Function],
|
||||
},
|
||||
"friendlyErrors": true,
|
||||
"hardSource": false,
|
||||
"hotMiddleware": Object {},
|
||||
"html": Object {
|
||||
"minify": Object {
|
||||
"collapseBooleanAttributes": true,
|
||||
"decodeEntities": true,
|
||||
"minifyCSS": true,
|
||||
"minifyJS": true,
|
||||
"processConditionalComments": true,
|
||||
"removeEmptyAttributes": true,
|
||||
"removeRedundantAttributes": true,
|
||||
"trimCustomFragments": true,
|
||||
"useShortDoctype": true,
|
||||
},
|
||||
},
|
||||
"loaders": Object {
|
||||
"css": Object {},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
},
|
||||
"file": Object {},
|
||||
"fontUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"imgUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"less": Object {},
|
||||
"pugPlain": Object {},
|
||||
"sass": Object {
|
||||
"indentedSyntax": true,
|
||||
},
|
||||
"scss": Object {},
|
||||
"stylus": Object {},
|
||||
"ts": Object {
|
||||
"appendTsSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"tsx": Object {
|
||||
"appendTsxSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"vue": Object {
|
||||
"transformAssetUrls": Object {
|
||||
"embed": "src",
|
||||
"object": "src",
|
||||
"source": "src",
|
||||
"video": "src",
|
||||
},
|
||||
},
|
||||
"vueStyle": Object {},
|
||||
},
|
||||
"optimization": Object {
|
||||
"minimize": undefined,
|
||||
"minimizer": undefined,
|
||||
"runtimeChunk": "single",
|
||||
"splitChunks": Object {
|
||||
"automaticNameDelimiter": ".",
|
||||
"cacheGroups": Object {},
|
||||
"chunks": "all",
|
||||
"name": undefined,
|
||||
},
|
||||
},
|
||||
"optimizeCSS": undefined,
|
||||
"parallel": false,
|
||||
"plugins": Array [],
|
||||
"postcss": Object {
|
||||
"preset": Object {
|
||||
"stage": 2,
|
||||
},
|
||||
},
|
||||
"profile": false,
|
||||
"publicPath": "/_nuxt/",
|
||||
"quiet": true,
|
||||
"splitChunks": Object {
|
||||
"commons": true,
|
||||
"layouts": false,
|
||||
"pages": true,
|
||||
},
|
||||
"ssr": undefined,
|
||||
"standalone": false,
|
||||
"stats": Object {
|
||||
"excludeAssets": Array [
|
||||
/\\.map\\$/,
|
||||
/index\\\\\\.\\.\\+\\\\\\.html\\$/,
|
||||
/vue-ssr-\\(client\\|modern\\)-manifest\\.json/,
|
||||
],
|
||||
},
|
||||
"styleResources": Object {},
|
||||
"template": undefined,
|
||||
"templates": Array [],
|
||||
"terser": Object {},
|
||||
"transpile": Array [],
|
||||
"useForkTsChecker": false,
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": ".nuxt",
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": undefined,
|
||||
"dev": false,
|
||||
"dir": Object {
|
||||
"assets": "assets",
|
||||
"layouts": "layouts",
|
||||
"middleware": "middleware",
|
||||
"pages": "pages",
|
||||
"static": "static",
|
||||
"store": "store",
|
||||
},
|
||||
"editor": undefined,
|
||||
"env": Object {},
|
||||
"extensions": Array [],
|
||||
"generate": Object {
|
||||
"concurrency": 500,
|
||||
"dir": "dist",
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"routes": Array [],
|
||||
"subFolders": true,
|
||||
},
|
||||
"globalName": "nuxt",
|
||||
"globals": Object {
|
||||
"context": [Function],
|
||||
"id": [Function],
|
||||
"loadedCallback": [Function],
|
||||
"nuxt": [Function],
|
||||
"pluginPrefix": [Function],
|
||||
"readyCallback": [Function],
|
||||
},
|
||||
"head": Object {
|
||||
"link": Array [],
|
||||
"meta": Array [],
|
||||
"script": Array [],
|
||||
"style": Array [],
|
||||
},
|
||||
"hooks": null,
|
||||
"ignore": Array [
|
||||
"**/*.test.*",
|
||||
"**/*.spec.*",
|
||||
],
|
||||
"ignorePrefix": "-",
|
||||
"layoutTransition": Object {
|
||||
"mode": "out-in",
|
||||
"name": "layout",
|
||||
},
|
||||
"layouts": Object {},
|
||||
"loading": Object {
|
||||
"color": "black",
|
||||
"continuous": false,
|
||||
"css": true,
|
||||
"duration": 5000,
|
||||
"failedColor": "red",
|
||||
"height": "2px",
|
||||
"rtl": false,
|
||||
"throttle": 200,
|
||||
},
|
||||
"loadingIndicator": "default",
|
||||
"messages": Object {
|
||||
"back_to_home": "Back to the home page",
|
||||
"client_error": "Error",
|
||||
"client_error_details": "An error occurred while rendering the page. Check developer tools console for details.",
|
||||
"error_404": "This page could not be found",
|
||||
"loading": "Loading...",
|
||||
"nuxtjs": "Nuxt.js",
|
||||
"server_error": "Server error",
|
||||
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
||||
},
|
||||
"mode": "universal",
|
||||
"modern": undefined,
|
||||
"modes": Object {
|
||||
"spa": Object {
|
||||
"build": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
},
|
||||
"universal": Object {
|
||||
"build": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"modules": Array [],
|
||||
"modulesDir": Array [
|
||||
"node_modules",
|
||||
],
|
||||
"plugins": Array [],
|
||||
"render": Object {
|
||||
"bundleRenderer": Object {
|
||||
"runInNewContext": undefined,
|
||||
"shouldPrefetch": [Function],
|
||||
"shouldPreload": [Function],
|
||||
},
|
||||
"compressor": Object {
|
||||
"threshold": 0,
|
||||
},
|
||||
"csp": false,
|
||||
"dist": Object {
|
||||
"index": false,
|
||||
"maxAge": "1y",
|
||||
},
|
||||
"etag": Object {
|
||||
"weak": false,
|
||||
},
|
||||
"fallback": Object {
|
||||
"dist": Object {},
|
||||
"static": Object {
|
||||
"handlers": Object {
|
||||
".htm": false,
|
||||
".html": false,
|
||||
},
|
||||
"skipUnknown": true,
|
||||
},
|
||||
},
|
||||
"http2": Object {
|
||||
"push": false,
|
||||
"pushAssets": null,
|
||||
"shouldPush": null,
|
||||
},
|
||||
"resourceHints": true,
|
||||
"ssr": undefined,
|
||||
"static": Object {
|
||||
"prefix": true,
|
||||
},
|
||||
},
|
||||
"router": Object {
|
||||
"base": "/",
|
||||
"extendRoutes": null,
|
||||
"fallback": false,
|
||||
"linkActiveClass": "nuxt-link-active",
|
||||
"linkExactActiveClass": "nuxt-link-exact-active",
|
||||
"linkPrefetchedClass": false,
|
||||
"middleware": Array [],
|
||||
"mode": "history",
|
||||
"parseQuery": false,
|
||||
"prefetchLinks": true,
|
||||
"routeNameSplitter": "-",
|
||||
"routes": Array [],
|
||||
"scrollBehavior": null,
|
||||
"stringifyQuery": false,
|
||||
},
|
||||
"server": Object {
|
||||
"host": "localhost",
|
||||
"https": false,
|
||||
"port": 3000,
|
||||
"socket": undefined,
|
||||
},
|
||||
"serverMiddleware": Array [],
|
||||
"srcDir": undefined,
|
||||
"styleExtensions": Array [
|
||||
"css",
|
||||
"pcss",
|
||||
"postcss",
|
||||
"styl",
|
||||
"stylus",
|
||||
"scss",
|
||||
"sass",
|
||||
"less",
|
||||
],
|
||||
"test": true,
|
||||
"transition": Object {
|
||||
"appear": false,
|
||||
"appearActiveClass": "appear-active",
|
||||
"appearClass": "appear",
|
||||
"appearToClass": "appear-to",
|
||||
"mode": "out-in",
|
||||
"name": "page",
|
||||
},
|
||||
"vue": Object {
|
||||
"config": Object {
|
||||
"performance": undefined,
|
||||
"silent": undefined,
|
||||
},
|
||||
},
|
||||
"watch": Array [],
|
||||
"watchers": Object {
|
||||
"chokidar": Object {
|
||||
"ignoreInitial": true,
|
||||
},
|
||||
"rewatchOnRawEvents": Array [
|
||||
"rename",
|
||||
],
|
||||
"webpack": Object {},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`config should return nuxt configurations with custom env 1`] = `
|
||||
Object {
|
||||
"ErrorPage": null,
|
||||
"_nuxtConfigFile": undefined,
|
||||
"build": Object {
|
||||
"analyze": false,
|
||||
"babel": Object {
|
||||
"babelrc": false,
|
||||
"cacheDirectory": undefined,
|
||||
},
|
||||
"cache": false,
|
||||
"crossorigin": undefined,
|
||||
"cssSourceMap": undefined,
|
||||
"devMiddleware": Object {},
|
||||
"extractCSS": false,
|
||||
"filenames": Object {
|
||||
"app": [Function],
|
||||
"chunk": [Function],
|
||||
"css": [Function],
|
||||
"font": [Function],
|
||||
"img": [Function],
|
||||
"video": [Function],
|
||||
},
|
||||
"friendlyErrors": true,
|
||||
"hardSource": false,
|
||||
"hotMiddleware": Object {},
|
||||
"html": Object {
|
||||
"minify": Object {
|
||||
"collapseBooleanAttributes": true,
|
||||
"decodeEntities": true,
|
||||
"minifyCSS": true,
|
||||
"minifyJS": true,
|
||||
"processConditionalComments": true,
|
||||
"removeEmptyAttributes": true,
|
||||
"removeRedundantAttributes": true,
|
||||
"trimCustomFragments": true,
|
||||
"useShortDoctype": true,
|
||||
},
|
||||
},
|
||||
"loaders": Object {
|
||||
"css": Object {},
|
||||
"cssModules": Object {
|
||||
"localIdentName": "[local]_[hash:base64:5]",
|
||||
},
|
||||
"file": Object {},
|
||||
"fontUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"imgUrl": Object {
|
||||
"limit": 1000,
|
||||
},
|
||||
"less": Object {},
|
||||
"pugPlain": Object {},
|
||||
"sass": Object {
|
||||
"indentedSyntax": true,
|
||||
},
|
||||
"scss": Object {},
|
||||
"stylus": Object {},
|
||||
"ts": Object {
|
||||
"appendTsSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"tsx": Object {
|
||||
"appendTsxSuffixTo": Array [
|
||||
/\\\\\\.vue\\$/,
|
||||
],
|
||||
"transpileOnly": true,
|
||||
},
|
||||
"vue": Object {
|
||||
"transformAssetUrls": Object {
|
||||
"embed": "src",
|
||||
"object": "src",
|
||||
"source": "src",
|
||||
"video": "src",
|
||||
},
|
||||
},
|
||||
"vueStyle": Object {},
|
||||
},
|
||||
"optimization": Object {
|
||||
"minimize": undefined,
|
||||
"minimizer": undefined,
|
||||
"runtimeChunk": "single",
|
||||
"splitChunks": Object {
|
||||
"automaticNameDelimiter": ".",
|
||||
"cacheGroups": Object {},
|
||||
"chunks": "all",
|
||||
"name": undefined,
|
||||
},
|
||||
},
|
||||
"optimizeCSS": undefined,
|
||||
"parallel": false,
|
||||
"plugins": Array [],
|
||||
"postcss": Object {
|
||||
"preset": Object {
|
||||
"stage": 2,
|
||||
},
|
||||
},
|
||||
"profile": false,
|
||||
"publicPath": "/_nuxt/",
|
||||
"quiet": true,
|
||||
"splitChunks": Object {
|
||||
"commons": true,
|
||||
"layouts": false,
|
||||
"pages": true,
|
||||
},
|
||||
"ssr": undefined,
|
||||
"standalone": false,
|
||||
"stats": Object {
|
||||
"excludeAssets": Array [
|
||||
/\\.map\\$/,
|
||||
/index\\\\\\.\\.\\+\\\\\\.html\\$/,
|
||||
/vue-ssr-\\(client\\|modern\\)-manifest\\.json/,
|
||||
],
|
||||
},
|
||||
"styleResources": Object {},
|
||||
"template": undefined,
|
||||
"templates": Array [],
|
||||
"terser": Object {},
|
||||
"transpile": Array [],
|
||||
"useForkTsChecker": false,
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": ".nuxt",
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": undefined,
|
||||
"dev": false,
|
||||
"dir": Object {
|
||||
"assets": "assets",
|
||||
"layouts": "layouts",
|
||||
"middleware": "middleware",
|
||||
"pages": "pages",
|
||||
"static": "static",
|
||||
"store": "store",
|
||||
},
|
||||
"editor": undefined,
|
||||
"env": Object {},
|
||||
"extensions": Array [],
|
||||
"generate": Object {
|
||||
"concurrency": 500,
|
||||
"dir": "dist",
|
||||
"fallback": "200.html",
|
||||
"interval": 0,
|
||||
"routes": Array [],
|
||||
"subFolders": true,
|
||||
},
|
||||
"globalName": "nuxt",
|
||||
"globals": Object {
|
||||
"context": [Function],
|
||||
"id": [Function],
|
||||
"loadedCallback": [Function],
|
||||
"nuxt": [Function],
|
||||
"pluginPrefix": [Function],
|
||||
"readyCallback": [Function],
|
||||
},
|
||||
"head": Object {
|
||||
"link": Array [],
|
||||
"meta": Array [],
|
||||
"script": Array [],
|
||||
"style": Array [],
|
||||
},
|
||||
"hooks": null,
|
||||
"ignore": Array [
|
||||
"**/*.test.*",
|
||||
"**/*.spec.*",
|
||||
],
|
||||
"ignorePrefix": "-",
|
||||
"layoutTransition": Object {
|
||||
"mode": "out-in",
|
||||
"name": "layout",
|
||||
},
|
||||
"layouts": Object {},
|
||||
"loading": Object {
|
||||
"color": "black",
|
||||
"continuous": false,
|
||||
"css": true,
|
||||
"duration": 5000,
|
||||
"failedColor": "red",
|
||||
"height": "2px",
|
||||
"rtl": false,
|
||||
"throttle": 200,
|
||||
},
|
||||
"loadingIndicator": "default",
|
||||
"messages": Object {
|
||||
"back_to_home": "Back to the home page",
|
||||
"client_error": "Error",
|
||||
"client_error_details": "An error occurred while rendering the page. Check developer tools console for details.",
|
||||
"error_404": "This page could not be found",
|
||||
"loading": "Loading...",
|
||||
"nuxtjs": "Nuxt.js",
|
||||
"server_error": "Server error",
|
||||
"server_error_details": "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.",
|
||||
},
|
||||
"mode": "universal",
|
||||
"modern": undefined,
|
||||
"modes": Object {
|
||||
"spa": Object {
|
||||
"build": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": false,
|
||||
},
|
||||
},
|
||||
"universal": Object {
|
||||
"build": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
"render": Object {
|
||||
"ssr": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"modules": Array [],
|
||||
"modulesDir": Array [
|
||||
"node_modules",
|
||||
],
|
||||
"plugins": Array [],
|
||||
"render": Object {
|
||||
"bundleRenderer": Object {
|
||||
"runInNewContext": undefined,
|
||||
"shouldPrefetch": [Function],
|
||||
"shouldPreload": [Function],
|
||||
},
|
||||
"compressor": Object {
|
||||
"threshold": 0,
|
||||
},
|
||||
"csp": false,
|
||||
"dist": Object {
|
||||
"index": false,
|
||||
"maxAge": "1y",
|
||||
},
|
||||
"etag": Object {
|
||||
"weak": false,
|
||||
},
|
||||
"fallback": Object {
|
||||
"dist": Object {},
|
||||
"static": Object {
|
||||
"handlers": Object {
|
||||
".htm": false,
|
||||
".html": false,
|
||||
},
|
||||
"skipUnknown": true,
|
||||
},
|
||||
},
|
||||
"http2": Object {
|
||||
"push": false,
|
||||
"pushAssets": null,
|
||||
"shouldPush": null,
|
||||
},
|
||||
"resourceHints": true,
|
||||
"ssr": undefined,
|
||||
"static": Object {
|
||||
"prefix": true,
|
||||
},
|
||||
},
|
||||
"router": Object {
|
||||
"base": "/",
|
||||
"extendRoutes": null,
|
||||
"fallback": false,
|
||||
"linkActiveClass": "nuxt-link-active",
|
||||
"linkExactActiveClass": "nuxt-link-exact-active",
|
||||
"linkPrefetchedClass": false,
|
||||
"middleware": Array [],
|
||||
"mode": "history",
|
||||
"parseQuery": false,
|
||||
"prefetchLinks": true,
|
||||
"routeNameSplitter": "-",
|
||||
"routes": Array [],
|
||||
"scrollBehavior": null,
|
||||
"stringifyQuery": false,
|
||||
},
|
||||
"server": Object {
|
||||
"host": "localhost",
|
||||
"https": false,
|
||||
"port": "3001",
|
||||
"socket": "/var/run/nuxt.sock",
|
||||
},
|
||||
"serverMiddleware": Array [],
|
||||
"srcDir": undefined,
|
||||
"styleExtensions": Array [
|
||||
"css",
|
||||
"pcss",
|
||||
"postcss",
|
||||
"styl",
|
||||
"stylus",
|
||||
"scss",
|
||||
"sass",
|
||||
"less",
|
||||
],
|
||||
"test": true,
|
||||
"transition": Object {
|
||||
"appear": false,
|
||||
"appearActiveClass": "appear-active",
|
||||
"appearClass": "appear",
|
||||
"appearToClass": "appear-to",
|
||||
"mode": "out-in",
|
||||
"name": "page",
|
||||
},
|
||||
"vue": Object {
|
||||
"config": Object {
|
||||
"performance": undefined,
|
||||
"silent": undefined,
|
||||
},
|
||||
},
|
||||
"watch": Array [],
|
||||
"watchers": Object {
|
||||
"chokidar": Object {
|
||||
"ignoreInitial": true,
|
||||
},
|
||||
"rewatchOnRawEvents": Array [
|
||||
"rename",
|
||||
],
|
||||
"webpack": Object {},
|
||||
},
|
||||
}
|
||||
`;
|
14
packages/config/test/config/_common.test.js
Normal file
14
packages/config/test/config/_common.test.js
Normal file
@ -0,0 +1,14 @@
|
||||
import commonConfig from '../../src/config/_common'
|
||||
|
||||
describe('config: common', () => {
|
||||
test('should return globals with given globalName', () => {
|
||||
const globalName = 'nuxt_global'
|
||||
const { globals } = commonConfig()
|
||||
expect(globals.id(globalName)).toEqual(`__nuxt_global`)
|
||||
expect(globals.nuxt(globalName)).toEqual(`$nuxt_global`)
|
||||
expect(globals.context(globalName)).toEqual(`__NUXT_GLOBAL__`)
|
||||
expect(globals.pluginPrefix(globalName)).toEqual('nuxt_global')
|
||||
expect(globals.readyCallback(globalName)).toEqual(`onNuxt_globalReady`)
|
||||
expect(globals.loadedCallback(globalName)).toEqual(`_onNuxt_globalLoaded`)
|
||||
})
|
||||
})
|
32
packages/config/test/config/build.test.js
Normal file
32
packages/config/test/config/build.test.js
Normal file
@ -0,0 +1,32 @@
|
||||
import buildConfig from '../../src/config/build'
|
||||
|
||||
describe('config: build', () => {
|
||||
test('should return dev filenames', () => {
|
||||
const { filenames } = buildConfig()
|
||||
const env = { isDev: true }
|
||||
expect(filenames.app(env)).toEqual('[name].js')
|
||||
expect(filenames.chunk(env)).toEqual('[name].js')
|
||||
expect(filenames.css(env)).toEqual('[name].css')
|
||||
expect(filenames.img(env)).toEqual('[path][name].[ext]')
|
||||
expect(filenames.font(env)).toEqual('[path][name].[ext]')
|
||||
expect(filenames.video(env)).toEqual('[path][name].[ext]')
|
||||
})
|
||||
|
||||
test('should return prod filenames', () => {
|
||||
const { filenames } = buildConfig()
|
||||
const env = { isDev: false }
|
||||
expect(filenames.app(env)).toEqual('[chunkhash].js')
|
||||
expect(filenames.chunk(env)).toEqual('[chunkhash].js')
|
||||
expect(filenames.css(env)).toEqual('[contenthash].css')
|
||||
expect(filenames.img(env)).toEqual('img/[hash:7].[ext]')
|
||||
expect(filenames.font(env)).toEqual('fonts/[hash:7].[ext]')
|
||||
expect(filenames.video(env)).toEqual('videos/[hash:7].[ext]')
|
||||
})
|
||||
|
||||
test('should return modern filenames', () => {
|
||||
const { filenames } = buildConfig()
|
||||
const env = { isDev: true, isModern: true }
|
||||
expect(filenames.app(env)).toEqual('modern-[name].js')
|
||||
expect(filenames.chunk(env)).toEqual('modern-[name].js')
|
||||
})
|
||||
})
|
16
packages/config/test/config/index.test.js
Normal file
16
packages/config/test/config/index.test.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { getDefaultNuxtConfig } from '../../src/config'
|
||||
|
||||
describe('config', () => {
|
||||
test('should return default nuxt configurations', () => {
|
||||
expect(getDefaultNuxtConfig()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should return nuxt configurations with custom env', () => {
|
||||
const env = {
|
||||
NUXT_PORT: '3001',
|
||||
NUXT_HOST: 'localhost',
|
||||
UNIX_SOCKET: '/var/run/nuxt.sock'
|
||||
}
|
||||
expect(getDefaultNuxtConfig({ env })).toMatchSnapshot()
|
||||
})
|
||||
})
|
19
packages/config/test/config/render.test.js
Normal file
19
packages/config/test/config/render.test.js
Normal file
@ -0,0 +1,19 @@
|
||||
import renderConfig from '../../src/config/render'
|
||||
|
||||
describe('config: render', () => {
|
||||
test('should return false in default shouldPrefetch', () => {
|
||||
const { bundleRenderer: { shouldPrefetch } } = renderConfig()
|
||||
expect(shouldPrefetch()).toEqual(false)
|
||||
})
|
||||
|
||||
test('should return true in script/style shouldPreload', () => {
|
||||
const { bundleRenderer: { shouldPreload } } = renderConfig()
|
||||
expect(shouldPreload(undefined, 'script')).toEqual(true)
|
||||
expect(shouldPreload(undefined, 'style')).toEqual(true)
|
||||
})
|
||||
|
||||
test('should return false in other shouldPreload', () => {
|
||||
const { bundleRenderer: { shouldPreload } } = renderConfig()
|
||||
expect(shouldPreload(undefined, 'font')).toEqual(false)
|
||||
})
|
||||
})
|
53
packages/config/test/config/server.test.js
Normal file
53
packages/config/test/config/server.test.js
Normal file
@ -0,0 +1,53 @@
|
||||
import serverConfig from '../../src/config/server'
|
||||
|
||||
describe('config: server', () => {
|
||||
test('should return default server configurations', () => {
|
||||
expect(serverConfig()).toEqual({
|
||||
https: false,
|
||||
port: 3000,
|
||||
host: 'localhost',
|
||||
socket: undefined
|
||||
})
|
||||
})
|
||||
|
||||
test('should return server configurations with NUXT_* env', () => {
|
||||
const env = {
|
||||
NUXT_PORT: 3001,
|
||||
NUXT_HOST: '127.0.0.1'
|
||||
}
|
||||
expect(serverConfig({ env })).toEqual({
|
||||
https: false,
|
||||
port: env.NUXT_PORT,
|
||||
host: env.NUXT_HOST,
|
||||
socket: undefined
|
||||
})
|
||||
})
|
||||
|
||||
test('should return server configurations with env', () => {
|
||||
const env = {
|
||||
PORT: 3002,
|
||||
HOST: 'local.env',
|
||||
UNIX_SOCKET: '/var/run/env.sock'
|
||||
}
|
||||
expect(serverConfig({ env })).toEqual({
|
||||
https: false,
|
||||
port: env.PORT,
|
||||
host: env.HOST,
|
||||
socket: env.UNIX_SOCKET
|
||||
})
|
||||
})
|
||||
|
||||
test('should return server configurations with npm_* env', () => {
|
||||
const env = {
|
||||
npm_package_config_nuxt_port: 3003,
|
||||
npm_package_config_nuxt_host: 'local.npm',
|
||||
npm_package_config_unix_socket: '/var/run/env.npm.sock'
|
||||
}
|
||||
expect(serverConfig({ env })).toEqual({
|
||||
https: false,
|
||||
port: env.npm_package_config_nuxt_port,
|
||||
host: env.npm_package_config_nuxt_host,
|
||||
socket: env.npm_package_config_unix_socket
|
||||
})
|
||||
})
|
||||
})
|
0
packages/config/test/fixtures/app.html
vendored
Normal file
0
packages/config/test/fixtures/app.html
vendored
Normal file
0
packages/config/test/fixtures/store/index.js
vendored
Normal file
0
packages/config/test/fixtures/store/index.js
vendored
Normal file
16
packages/config/test/index.test.js
Normal file
16
packages/config/test/index.test.js
Normal file
@ -0,0 +1,16 @@
|
||||
import { getDefaultNuxtConfig, getNuxtConfig } from '../src'
|
||||
|
||||
jest.mock('../src/options', () => ({
|
||||
getNuxtConfig: jest.fn().mockReturnValue('nuxt config')
|
||||
}))
|
||||
|
||||
jest.mock('../src/config', () => ({
|
||||
getDefaultNuxtConfig: jest.fn().mockReturnValue('default nuxt config')
|
||||
}))
|
||||
|
||||
describe('config: entry', () => {
|
||||
test('should export getDefaultNuxtConfig and getNuxtConfig', () => {
|
||||
expect(getNuxtConfig()).toEqual('nuxt config')
|
||||
expect(getDefaultNuxtConfig()).toEqual('default nuxt config')
|
||||
})
|
||||
})
|
192
packages/config/test/options.test.js
Normal file
192
packages/config/test/options.test.js
Normal file
@ -0,0 +1,192 @@
|
||||
import path from 'path'
|
||||
import consola from 'consola'
|
||||
import { getNuxtConfig } from '../src/options'
|
||||
|
||||
describe('config: options', () => {
|
||||
test('should return default nuxt config', () => {
|
||||
expect(getNuxtConfig({})).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should prevent duplicate calls with same options', () => {
|
||||
const options = {}
|
||||
const firstConfig = getNuxtConfig(options)
|
||||
const secondConfig = getNuxtConfig(firstConfig)
|
||||
|
||||
expect(firstConfig).toBe(secondConfig)
|
||||
expect(firstConfig.__normalized__).toBe(true)
|
||||
})
|
||||
|
||||
test('should return default loading when loading is true', () => {
|
||||
const { loading } = getNuxtConfig({ loading: true })
|
||||
expect(loading).toEqual({
|
||||
color: 'black',
|
||||
failedColor: 'red',
|
||||
height: '2px',
|
||||
throttle: 200,
|
||||
duration: 5000,
|
||||
continuous: false,
|
||||
rtl: false,
|
||||
css: true
|
||||
})
|
||||
})
|
||||
|
||||
test('should transform transition/layoutTransition to name', () => {
|
||||
const { transition, layoutTransition } = getNuxtConfig({
|
||||
transition: 'test-tran',
|
||||
layoutTransition: 'test-layout-tran'
|
||||
})
|
||||
expect(transition).toMatchObject({ name: 'test-tran' })
|
||||
expect(layoutTransition).toMatchObject({ name: 'test-layout-tran' })
|
||||
})
|
||||
|
||||
test('should transform extensions to array', () => {
|
||||
const { extensions } = getNuxtConfig({ extensions: 'ext' })
|
||||
expect(extensions).toEqual(['js', 'mjs', 'ts', 'ext'])
|
||||
})
|
||||
|
||||
test('should support custom global name', () => {
|
||||
const { globalName } = getNuxtConfig({ globalName: 'globalNuxt' })
|
||||
expect(globalName).toEqual('globalnuxt')
|
||||
})
|
||||
|
||||
test('should detect store dir', () => {
|
||||
const { store } = getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
||||
expect(store).toEqual(true)
|
||||
})
|
||||
|
||||
test('should enable csp', () => {
|
||||
const { render: { csp } } = getNuxtConfig({ render: { csp: { allowedSources: true, test: true } } })
|
||||
expect(csp).toEqual({
|
||||
hashAlgorithm: 'sha256',
|
||||
allowedSources: true,
|
||||
policies: undefined,
|
||||
reportOnly: false,
|
||||
test: true
|
||||
})
|
||||
})
|
||||
|
||||
test('should check unknown mode', () => {
|
||||
const { build, render } = getNuxtConfig({ mode: 'test' })
|
||||
expect(consola.warn).toHaveBeenCalledWith('Unknown mode: test. Falling back to universal')
|
||||
expect(build.ssr).toEqual(true)
|
||||
expect(render.ssr).toEqual(true)
|
||||
})
|
||||
|
||||
test('should return 404.html as default generate.fallback', () => {
|
||||
const { generate: { fallback } } = getNuxtConfig({ generate: { fallback: true } })
|
||||
expect(fallback).toEqual('404.html')
|
||||
})
|
||||
|
||||
describe('config: router dir', () => {
|
||||
test('should transform middleware to array', () => {
|
||||
const { router: { middleware } } = getNuxtConfig({ router: { middleware: 'midd' } })
|
||||
expect(middleware).toEqual(['midd'])
|
||||
})
|
||||
|
||||
test('should set _routerBaseSpecified when base is specified', () => {
|
||||
const { _routerBaseSpecified } = getNuxtConfig({ router: { base: '/test' } })
|
||||
expect(_routerBaseSpecified).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('config: options dir', () => {
|
||||
test('should support custom root dir', () => {
|
||||
const { rootDir } = getNuxtConfig({
|
||||
rootDir: 'root'
|
||||
})
|
||||
expect(rootDir).toEqual(path.resolve('root'))
|
||||
})
|
||||
|
||||
test('should support custom src dir', () => {
|
||||
const { srcDir } = getNuxtConfig({
|
||||
rootDir: 'root',
|
||||
srcDir: 'src'
|
||||
})
|
||||
expect(srcDir).toEqual(path.resolve('root', 'src'))
|
||||
})
|
||||
|
||||
test('should support custom generate dir', () => {
|
||||
const { generate: { dir } } = getNuxtConfig({
|
||||
rootDir: 'root',
|
||||
generate: { dir: 'generate' }
|
||||
})
|
||||
expect(dir).toEqual(path.resolve('root', 'generate'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('config: options template', () => {
|
||||
test('should use default appTemplatePath', () => {
|
||||
const { appTemplatePath } = getNuxtConfig({})
|
||||
expect(appTemplatePath).toEqual(path.resolve('.nuxt', 'views', 'app.template.html'))
|
||||
})
|
||||
|
||||
test('should use custom appTemplatePath', () => {
|
||||
const { appTemplatePath } = getNuxtConfig({ appTemplatePath: 'templates' })
|
||||
expect(appTemplatePath).toEqual(path.resolve('templates'))
|
||||
})
|
||||
|
||||
test('should use custom app.html', () => {
|
||||
const { appTemplatePath } = getNuxtConfig({ rootDir: path.resolve(__dirname, 'fixtures') })
|
||||
expect(appTemplatePath).toEqual(path.resolve(__dirname, 'fixtures', 'app.html'))
|
||||
})
|
||||
})
|
||||
|
||||
describe('config: options publicPath', () => {
|
||||
test('should fallback to default when publicPath is falsy', () => {
|
||||
const { build: { publicPath } } = getNuxtConfig({ build: { publicPath: false } })
|
||||
expect(publicPath).toEqual('/_nuxt/')
|
||||
})
|
||||
|
||||
test('should append slash in publicPath', () => {
|
||||
const { build: { publicPath } } = getNuxtConfig({ build: { publicPath: '/nuxt_public' } })
|
||||
expect(publicPath).toEqual('/nuxt_public/')
|
||||
})
|
||||
|
||||
test('should ignore url publicPath in dev', () => {
|
||||
const { build: { publicPath } } = getNuxtConfig({ dev: true, build: { publicPath: 'http://nuxt_public' } })
|
||||
expect(publicPath).toEqual('/_nuxt/')
|
||||
})
|
||||
})
|
||||
|
||||
describe('config: options babel', () => {
|
||||
test('should replace and deprecate @nuxtjs/babel-preset-app', () => {
|
||||
const { build: { babel } } = getNuxtConfig({
|
||||
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(babel).toEqual({
|
||||
'babelrc': false,
|
||||
'cacheDirectory': false,
|
||||
'presets': ['@nuxt/babel-preset-app']
|
||||
})
|
||||
})
|
||||
|
||||
test('should support options in babel presets', () => {
|
||||
const { build: { babel } } = getNuxtConfig({
|
||||
build: { babel: { presets: [['@nuxt/babel-preset-app', { test: true }]] } }
|
||||
})
|
||||
expect(babel).toEqual({
|
||||
'babelrc': false,
|
||||
'cacheDirectory': false,
|
||||
'presets': [['@nuxt/babel-preset-app', { test: true }]]
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('config: options deprecated', () => {
|
||||
test('should deprecate render.gzip', () => {
|
||||
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')
|
||||
})
|
||||
|
||||
test('should deprecate build.vendor', () => {
|
||||
getNuxtConfig({ build: { vendor: ['lodash'] } })
|
||||
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization')
|
||||
})
|
||||
|
||||
test('should deprecate build.extractCSS.allChunks', () => {
|
||||
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.')
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user