mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 14:11:07 +00:00
refactor: create case for webpack config
This commit is contained in:
parent
a15479fbd5
commit
a9e05b4e6b
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
import path from 'path'
|
|
||||||
import { Utils } from '../utils'
|
import { Utils } from '../utils'
|
||||||
import PerfLoader from '../../lib/builder/webpack/utils/perf-loader'
|
|
||||||
|
|
||||||
describe('utils', () => {
|
describe('utils', () => {
|
||||||
test('encodeHtml', () => {
|
test('encodeHtml', () => {
|
||||||
@ -200,34 +198,6 @@ describe('utils', () => {
|
|||||||
const chainedFn = Utils.chainFn(firstFn, secondFn)
|
const chainedFn = Utils.chainFn(firstFn, secondFn)
|
||||||
expect(chainedFn({}, 10)).toEqual({ foo: 11, bar: 12 })
|
expect(chainedFn({}, 10)).toEqual({ foo: 11, bar: 12 })
|
||||||
})
|
})
|
||||||
|
|
||||||
test('performance loader', () => {
|
|
||||||
const perfLoader = new PerfLoader({
|
|
||||||
dev: true,
|
|
||||||
build: {
|
|
||||||
parallel: true,
|
|
||||||
cache: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const js = { name: 'js', poolTimeout: Infinity }
|
|
||||||
const css = { name: 'css', poolTimeout: Infinity }
|
|
||||||
expect(perfLoader.workerPools).toMatchObject({ js, css })
|
|
||||||
|
|
||||||
const warmup = jest.fn()
|
|
||||||
perfLoader.threadLoader = { warmup }
|
|
||||||
perfLoader.warmup()
|
|
||||||
expect(warmup).toHaveBeenCalledTimes(2)
|
|
||||||
expect(warmup).toHaveBeenCalledWith(js, ['babel-loader', 'babel-preset-env'])
|
|
||||||
expect(warmup).toHaveBeenCalledWith(css, ['css-loader'])
|
|
||||||
|
|
||||||
const loaders = perfLoader.pool('js', { loader: 'test-perf-loader' })
|
|
||||||
const cacheDirectory = path.resolve('node_modules/.cache/cache-loader')
|
|
||||||
expect(loaders).toMatchObject([
|
|
||||||
{ loader: 'cache-loader', options: { cacheDirectory } },
|
|
||||||
{ loader: 'thread-loader', options: js },
|
|
||||||
{ loader: 'test-perf-loader' }
|
|
||||||
])
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('createRoutes should allow snake case routes', () => {
|
test('createRoutes should allow snake case routes', () => {
|
||||||
|
33
test/unit/wp.config.test.js
Normal file
33
test/unit/wp.config.test.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
import path from 'path'
|
||||||
|
import PerfLoader from '../../lib/builder/webpack/utils/perf-loader'
|
||||||
|
|
||||||
|
describe('webpack configuration', () => {
|
||||||
|
test('performance loader', () => {
|
||||||
|
const perfLoader = new PerfLoader({
|
||||||
|
dev: true,
|
||||||
|
build: {
|
||||||
|
parallel: true,
|
||||||
|
cache: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const js = { name: 'js', poolTimeout: Infinity }
|
||||||
|
const css = { name: 'css', poolTimeout: Infinity }
|
||||||
|
expect(perfLoader.workerPools).toMatchObject({ js, css })
|
||||||
|
|
||||||
|
const warmup = jest.fn()
|
||||||
|
perfLoader.threadLoader = { warmup }
|
||||||
|
perfLoader.warmup()
|
||||||
|
expect(warmup).toHaveBeenCalledTimes(2)
|
||||||
|
expect(warmup).toHaveBeenCalledWith(js, ['babel-loader', 'babel-preset-env'])
|
||||||
|
expect(warmup).toHaveBeenCalledWith(css, ['css-loader'])
|
||||||
|
|
||||||
|
const loaders = perfLoader.pool('js', { loader: 'test-perf-loader' })
|
||||||
|
const cacheDirectory = path.resolve('node_modules/.cache/cache-loader')
|
||||||
|
expect(loaders).toMatchObject([
|
||||||
|
{ loader: 'cache-loader', options: { cacheDirectory } },
|
||||||
|
{ loader: 'thread-loader', options: js },
|
||||||
|
{ loader: 'test-perf-loader' }
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user