mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-06 06:03:58 +00:00
0f104aa588
- Better insights and inspection for server bundle - Remove all vue related dependencies from vue-renderer package as much as possible to reduce install size of nuxt-start - Support for single file distributions (serverless) - Remove server-bundle.json and use the standard .js files for dist/server - Mitigate CALL_AND_RETRY_LAST Allocation failed errors. Most of the cases happen on JSON.parse() the part when loading bundle. (#4225, #3465, #1728, #1601, #1481) - Reduce server dist size by removing escape characters caused by JSON serialize - Faster dev reloads and production start by removing extra JSON.serialize/JSON.parse time - Less memory usage - General performance improvements and refactors
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
import { resolve } from 'path'
|
|
import { loadFixture, getPort, Nuxt, Builder } from '../utils'
|
|
|
|
describe('nuxt', () => {
|
|
test('Nuxt.js Class', () => {
|
|
expect(typeof Nuxt).toBe('function')
|
|
})
|
|
|
|
test('Nuxt.js Instance', async () => {
|
|
const config = await loadFixture('empty')
|
|
const nuxt = new Nuxt(config)
|
|
|
|
expect(typeof nuxt).toBe('object')
|
|
expect(nuxt.options.dev).toBe(false)
|
|
expect(typeof nuxt._ready.then).toBe('function')
|
|
|
|
await nuxt.ready()
|
|
|
|
expect(nuxt.initialized).toBe(true)
|
|
})
|
|
|
|
test('Fail to build when no pages/ directory but is in the parent', async () => {
|
|
const config = await loadFixture('empty')
|
|
const nuxt = new Nuxt({
|
|
...config,
|
|
rootDir: resolve(__dirname, '..', 'fixtures', 'empty', 'pages')
|
|
})
|
|
|
|
try {
|
|
await new Builder(nuxt).build()
|
|
} catch (err) {
|
|
expect(err.message).toContain('No `pages` directory found')
|
|
expect(err.message).toContain('Did you mean to run `nuxt` in the parent (`../`) directory?')
|
|
}
|
|
expect.hasAssertions()
|
|
})
|
|
|
|
test('Build with default page when no pages/ directory', async () => {
|
|
const config = await loadFixture('missing-pages-dir')
|
|
const nuxt = new Nuxt(config)
|
|
const port = await getPort()
|
|
await nuxt.server.listen(port, 'localhost')
|
|
|
|
const { html } = await nuxt.server.renderRoute('/')
|
|
expect(html).toContain('<h2 class="Landscape__Title">')
|
|
expect(/Landscape__Page__Explanation/.test(html)).toBe(true)
|
|
|
|
await nuxt.close()
|
|
})
|
|
|
|
test('Fail to build when specified plugin isn\'t found', async () => {
|
|
const config = await loadFixture('missing-plugin')
|
|
const nuxt = new Nuxt(config)
|
|
|
|
await expect(new Builder(nuxt).build()).rejects.toThrow('Plugin not found')
|
|
})
|
|
|
|
test('Warn when styleResource isn\'t found', async () => {
|
|
const config = await loadFixture('missing-style-resource')
|
|
const nuxt = new Nuxt(config)
|
|
|
|
await expect(new Builder(nuxt).build()).rejects.toThrow('Style Resource not found')
|
|
})
|
|
})
|