2018-08-08 19:05:23 +00:00
|
|
|
import Browser from '../utils/browser'
|
|
|
|
import { getPort, loadFixture, Nuxt } from '../utils'
|
|
|
|
|
|
|
|
let port
|
|
|
|
const browser = new Browser()
|
|
|
|
const url = route => 'http://localhost:' + port + route
|
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
let page = null
|
|
|
|
|
|
|
|
const startServer = async (type = 'basic') => {
|
2018-08-17 20:25:23 +00:00
|
|
|
const config = await loadFixture(type)
|
2018-08-08 19:05:23 +00:00
|
|
|
nuxt = new Nuxt(config)
|
|
|
|
port = await getPort()
|
2018-10-30 20:42:53 +00:00
|
|
|
await nuxt.server.listen(port, 'localhost')
|
2018-08-08 19:05:23 +00:00
|
|
|
|
|
|
|
return nuxt
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('basic vue-config', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await browser.start({
|
|
|
|
// slowMo: 50,
|
|
|
|
// headless: false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('default', async () => {
|
|
|
|
nuxt = await startServer()
|
|
|
|
expect(nuxt.options.vue.config).toEqual({ silent: true, performance: false })
|
|
|
|
page = await browser.page(url('/config'))
|
|
|
|
|
2018-11-24 18:49:19 +00:00
|
|
|
expect(await page.$text('#silent', true)).toBe('true')
|
|
|
|
expect(await page.$text('#performance', true)).toBe('false')
|
2018-08-08 19:05:23 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('explicit', async () => {
|
|
|
|
nuxt = await startServer('config-explicit')
|
|
|
|
page = await browser.page(url('/config'))
|
|
|
|
|
|
|
|
expect(nuxt.options.vue.config).toEqual({ silent: false, performance: true, devtools: true })
|
|
|
|
|
2018-11-24 18:49:19 +00:00
|
|
|
expect(await page.$text('#silent', true)).toBe('false')
|
|
|
|
expect(await page.$text('#performance', true)).toBe('true')
|
|
|
|
expect(await page.$text('#devtools', true)).toBe('true')
|
2018-08-08 19:05:23 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await page.close()
|
|
|
|
await browser.close()
|
|
|
|
})
|
|
|
|
})
|