mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +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
53 lines
1.7 KiB
JavaScript
Executable File
53 lines
1.7 KiB
JavaScript
Executable File
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
import rp from 'request-promise-native'
|
|
import { Nuxt, Builder } from '..'
|
|
import { intercept, interceptWarn, release } from './helpers/console'
|
|
|
|
const port = 4010
|
|
const url = (route) => 'http://localhost:' + port + route
|
|
|
|
let nuxt = null
|
|
let builder = null
|
|
let buildSpies = null
|
|
|
|
// Init nuxt.js and create server listening on localhost:4000
|
|
test.serial('Init Nuxt.js', async t => {
|
|
const rootDir = resolve(__dirname, 'fixtures/deprecate')
|
|
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
|
config.rootDir = rootDir
|
|
config.dev = false
|
|
|
|
buildSpies = await intercept(async () => {
|
|
nuxt = new Nuxt(config)
|
|
builder = await new Builder(nuxt)
|
|
await builder.build()
|
|
await nuxt.listen(port, 'localhost')
|
|
})
|
|
|
|
t.true(buildSpies.log.calledWithMatch('DONE'))
|
|
t.true(buildSpies.log.calledWithMatch('OPEN'))
|
|
})
|
|
|
|
test.serial('Deprecated: context.isServer and context.isClient', async t => {
|
|
const warnSpy = await interceptWarn()
|
|
await rp(url('/'))
|
|
t.true(warnSpy.calledWith('context.isServer has been deprecated, please use process.server instead.'))
|
|
t.true(warnSpy.calledWith('context.isClient has been deprecated, please use process.client instead.'))
|
|
t.true(warnSpy.calledTwice)
|
|
release()
|
|
})
|
|
|
|
test.serial('Deprecated: dev in build.extend()', async t => {
|
|
t.true(buildSpies.warn.withArgs('dev has been deprecated in build.extend(), please use isDev').calledTwice)
|
|
})
|
|
|
|
test.serial('Deprecated: nuxt.plugin()', async t => {
|
|
t.true(nuxt.__builder_plugin)
|
|
})
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
test.after.always('Closing server and nuxt.js', async t => {
|
|
await nuxt.close()
|
|
})
|