Nuxt/test/unit/unicode-base.size-limit.test.js

28 lines
897 B
JavaScript
Raw Normal View History

import { resolve } from 'path'
import { getResourcesSize } from '../utils'
const distDir = resolve(__dirname, '../fixtures/unicode-base/.nuxt/dist')
describe('nuxt minimal vue-app bundle size limit', () => {
expect.extend({
toBeWithinSize (received, size) {
const maxSize = size * 1.02
const minSize = size * 0.98
const pass = received >= minSize && received <= maxSize
return {
pass,
message: () =>
`expected ${received} to be within range ${minSize} - ${maxSize}`
}
}
})
it('should stay within the size limit range', async () => {
const filter = filename => filename === 'vue-app.nuxt.js'
const legacyResourcesSize = await getResourcesSize(distDir, 'client', { filter })
2020-01-17 13:27:10 +00:00
const LEGACY_JS_RESOURCES_KB_SIZE = 15.7
expect(legacyResourcesSize.uncompressed).toBeWithinSize(LEGACY_JS_RESOURCES_KB_SIZE)
})
})