mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-05 21:53:56 +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
46 lines
998 B
JavaScript
46 lines
998 B
JavaScript
import test from 'ava'
|
|
import { resolve } from 'path'
|
|
import { Nuxt, Builder } from '..'
|
|
import express from 'express'
|
|
import rp from 'request-promise-native'
|
|
import { interceptLog } from './helpers/console'
|
|
|
|
const port = 4000
|
|
const url = (route) => 'http://localhost:' + port + route
|
|
|
|
let nuxt
|
|
let app
|
|
|
|
// Init nuxt.js and create express server
|
|
test.serial('Init Nuxt.js', async t => {
|
|
const config = {
|
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
|
buildDir: '.nuxt-express',
|
|
dev: false,
|
|
build: {
|
|
stats: false
|
|
}
|
|
}
|
|
|
|
const logSpy = await interceptLog(async () => {
|
|
nuxt = new Nuxt(config)
|
|
await new Builder(nuxt).build()
|
|
})
|
|
t.true(logSpy.calledWithMatch('DONE'))
|
|
|
|
// Create express app
|
|
app = express()
|
|
|
|
// Register nuxt
|
|
app.use(nuxt.render)
|
|
|
|
// Start listening on localhost:4000
|
|
app.listen(port)
|
|
})
|
|
|
|
test('/stateless with express', async t => {
|
|
const html = await rp(url('/stateless'))
|
|
|
|
t.true(html.includes('<h1>My component!</h1>'))
|
|
})
|