mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fffe741986
Add stdout/stderr to console helpers Remove separate nosubfolders test file in favor of inclusion in basic.generate Add build.stats to silence webpack output Add .always to after hooks: (1) fixes issue with basic.dev test that watch.js is empty when one of the test fails and (2) fixes that sometimes when running multiple tests that failed after eachother the port is still used as the server did not automatically get killed Change all init nuxt before test to serial tests and add tests for DONE and OPEN logs
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
import { promisify } from 'util'
|
|
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
import fs from 'fs'
|
|
import { Nuxt, Builder } from '..'
|
|
import { interceptLog, release } from './helpers/console'
|
|
|
|
const readFile = promisify(fs.readFile)
|
|
const rootDir = resolve(__dirname, 'fixtures/dll')
|
|
const dllDir = resolve(rootDir, '.cache/client-dll')
|
|
|
|
const checkCache = (lib) => {
|
|
return async (t) => {
|
|
const manifest = await readFile(resolve(dllDir, `./${lib}-manifest.json`), 'utf-8')
|
|
t.truthy(JSON.parse(manifest).name)
|
|
t.true(fs.existsSync(resolve(dllDir, `./${JSON.parse(manifest).name}.js`)))
|
|
}
|
|
}
|
|
|
|
let nuxt
|
|
|
|
test.serial('Init Nuxt.js', async t => {
|
|
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
|
config.rootDir = rootDir
|
|
config.dev = true
|
|
|
|
const logSpy = await interceptLog(async () => {
|
|
nuxt = new Nuxt(config)
|
|
await new Builder(nuxt).build()
|
|
})
|
|
t.true(logSpy.calledWithMatch('DONE'))
|
|
})
|
|
|
|
test('Check vue cache', checkCache('vue'))
|
|
|
|
test('Check vue-meta cache', checkCache('vue-meta'))
|
|
|
|
test('Check vue-router cache', checkCache('vue-router'))
|
|
|
|
test('Build with DllReferencePlugin', async t => {
|
|
const logSpy = await interceptLog()
|
|
await new Builder(nuxt).build()
|
|
release()
|
|
t.true(logSpy.withArgs('Using dll for 3 libs').calledOnce)
|
|
})
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
test.after.always('Closing nuxt.js', t => {
|
|
nuxt.close()
|
|
})
|