2018-03-19 10:06:45 +00:00
|
|
|
import { Nuxt, Builder } from '../../'
|
|
|
|
import { loadFixture, getPort } from '../utils'
|
2017-06-16 12:49:35 +00:00
|
|
|
|
2018-03-18 23:41:14 +00:00
|
|
|
let port
|
2018-01-13 05:22:11 +00:00
|
|
|
const url = route => 'http://localhost:' + port + route
|
2016-12-21 19:51:43 +00:00
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
|
2018-03-18 19:31:32 +00:00
|
|
|
describe('basic dev', () => {
|
|
|
|
beforeAll(async () => {
|
2018-03-18 23:41:14 +00:00
|
|
|
const config = loadFixture('basic', { buildDir: '.nuxt-dev' })
|
|
|
|
config.dev = true
|
|
|
|
nuxt = new Nuxt(config)
|
2018-03-18 19:31:32 +00:00
|
|
|
new Builder(nuxt).build()
|
2018-03-18 23:41:14 +00:00
|
|
|
port = await getPort()
|
2017-12-17 19:30:26 +00:00
|
|
|
await nuxt.listen(port, 'localhost')
|
2018-03-18 23:41:14 +00:00
|
|
|
})
|
2018-03-18 19:31:32 +00:00
|
|
|
|
|
|
|
// TODO: enable test when style-loader.js:60 was resolved
|
|
|
|
// test.serial('/extractCSS', async t => {
|
|
|
|
// const window = await nuxt.renderAndGetWindow(url('/extractCSS'))
|
|
|
|
// const html = window.document.head.innerHTML
|
|
|
|
// t.true(html.includes('vendor.css'))
|
|
|
|
// t.true(!html.includes('30px'))
|
|
|
|
// t.is(window.getComputedStyle(window.document.body).getPropertyValue('font-size'), '30px')
|
|
|
|
// })
|
|
|
|
|
|
|
|
test('/stateless', async () => {
|
|
|
|
// const spies = await intercept()
|
|
|
|
const window = await nuxt.renderAndGetWindow(url('/stateless'))
|
|
|
|
const html = window.document.body.innerHTML
|
|
|
|
expect(html.includes('<h1>My component!</h1>')).toBe(true)
|
|
|
|
// expect(spies.info.calledWithMatch('You are running Vue in development mode.')).toBe(true)
|
|
|
|
// release()
|
2017-12-17 19:30:26 +00:00
|
|
|
})
|
|
|
|
|
2018-03-18 19:31:32 +00:00
|
|
|
// test('/_nuxt/test.hot-update.json should returns empty html', async t => {
|
|
|
|
// try {
|
|
|
|
// await rp(url('/_nuxt/test.hot-update.json'))
|
|
|
|
// } catch (err) {
|
|
|
|
// t.is(err.statusCode, 404)
|
|
|
|
// t.is(err.response.body, '')
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
test('Closing server and nuxt.js', async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
2016-12-21 19:51:43 +00:00
|
|
|
})
|