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()
|
2023-10-16 21:23:38 +00:00
|
|
|
const url = route => 'http://127.0.0.1:' + port + route
|
2018-08-08 19:05:23 +00:00
|
|
|
|
|
|
|
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)
|
2019-03-08 20:43:23 +00:00
|
|
|
await nuxt.ready()
|
|
|
|
|
2018-08-08 19:05:23 +00:00
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
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()
|
|
|
|
})
|
|
|
|
})
|