import { resolve } from 'path' import { Nuxt, Builder } from '..' const port = 4013 // const url = (route) => 'http://localhost:' + port + route let nuxt = null describe('children', () => { // Init nuxt.js and create server listening on localhost:4000 beforeAll(async () => { const options = { rootDir: resolve(__dirname, 'fixtures/children'), dev: false, build: { stats: false } } nuxt = new Nuxt(options) new Builder(nuxt).build() await nuxt.listen(port, 'localhost') }, 30000) test('/parent', async () => { const { html } = await nuxt.renderRoute('/parent') expect(html.includes('

I am the parent

')).toBe(true) }) test('/parent/child', async () => { const { html } = await nuxt.renderRoute('/parent/child') expect(html.includes('

I am the parent

')).toBe(true) expect(html.includes('

I am the child

')).toBe(true) }) test('/parent should call _id.vue', async () => { const { html } = await nuxt.renderRoute('/parent') expect(html.includes('

I am the parent

')).toBe(true) expect(html.includes('

Id=

')).toBe(true) }) test('/parent/1', async () => { const { html } = await nuxt.renderRoute('/parent/1') expect(html.includes('

I am the parent

')).toBe(true) expect(html.includes('

Id=1

')).toBe(true) }) test('/parent/validate-child should display 404', async () => { const { html } = await nuxt.renderRoute('/parent/validate-child') expect(html.includes('This page could not be found')).toBe(true) }) test('/parent/validate-child?key=12345', async () => { const { html } = await nuxt.renderRoute('/parent/validate-child?key=12345') expect(html.includes('

I am the parent

')).toBe(true) expect(html.includes('

Child valid

')).toBe(true) }) // Close server and ask nuxt to stop listening to file changes test('Closing server and nuxt.js', async () => { await nuxt.close() }) })