2018-08-17 20:25:23 +00:00
import consola from 'consola'
import { buildFixture } from '../../utils/build'
2018-03-27 22:28:17 +00:00
2018-09-08 21:08:25 +00:00
beforeAll ( ( ) => {
process . env . NUXT _ENV _FOO = 'manniL'
} )
2018-09-08 20:18:14 +00:00
let customCompressionMiddlewareFunctionName
const hooks = [
[ 'render:errorMiddleware' , ( app ) => {
customCompressionMiddlewareFunctionName = app . stack [ 0 ] . handle . name
} ]
]
2018-08-16 15:34:32 +00:00
describe ( 'with-config' , ( ) => {
buildFixture ( 'with-config' , ( ) => {
2019-03-30 19:12:12 +00:00
expect ( consola . warn ) . toHaveBeenCalledTimes ( 6 )
2018-09-08 20:18:14 +00:00
expect ( consola . fatal ) . toHaveBeenCalledTimes ( 0 )
2018-09-30 16:11:20 +00:00
expect ( consola . warn . mock . calls ) . toMatchObject ( [
2019-03-30 19:12:12 +00:00
[ 'Unknown mode: unknown. Falling back to universal' ] ,
[ 'Invalid plugin mode (server/client/all): \'abc\'. Falling back to \'all\'' ] ,
2018-09-30 16:11:20 +00:00
[ {
2019-03-30 19:12:12 +00:00
'additional' : expect . stringContaining ( 'plugins/test.json' ) ,
'message' : 'Found 2 plugins that match the configuration, suggest to specify extension:'
2018-09-30 16:11:20 +00:00
} ] ,
2019-03-30 19:12:12 +00:00
[ 'Please use `build.postcss` in your nuxt.config.js instead of an external config file. Support for such files will be removed in Nuxt 3 as they remove all defaults set by Nuxt and can cause severe problems with features like alias resolving inside your CSS.' ] ,
2019-04-11 10:04:52 +00:00
[ 'Using styleResources without the @nuxtjs/style-resources is not suggested and can lead to severe performance issues.' , 'Please use https://github.com/nuxt-community/style-resources-module' ] ,
2019-03-30 19:12:12 +00:00
[ 'Notice: Please do not deploy bundles built with analyze mode, it\'s only for analyzing purpose.' ]
2018-09-30 16:11:20 +00:00
] )
2018-09-08 20:18:14 +00:00
expect ( customCompressionMiddlewareFunctionName ) . toBe ( 'damn' )
} , hooks )
2018-08-16 15:34:32 +00:00
} )
2018-09-08 21:08:25 +00:00
afterAll ( ( ) => {
delete process . env . NUXT _ENV _FOO
} )