import consola from 'consola' import { loadFixture, getPort, Nuxt, wChunk } from '../utils' let nuxt, port const url = route => 'http://localhost:' + port + route const renderRoute = async (_url) => { const window = await nuxt.server.renderAndGetWindow(url(_url)) const head = window.document.head.innerHTML const html = window.document.body.innerHTML return { window, head, html } } describe('spa', () => { beforeAll(async () => { const config = await loadFixture('spa') nuxt = new Nuxt(config) await nuxt.ready() port = await getPort() await nuxt.server.listen(port, 'localhost') }) test('/ (basic spa)', async () => { const { html } = await renderRoute('/') expect(html).toMatch('Hello SPA!') expect(consola.log).not.toHaveBeenCalledWith('created') expect(consola.log).toHaveBeenCalledWith('mounted') consola.log.mockClear() }) test('/ (include preload and prefetch resources)', async () => { const { head } = await renderRoute('/') expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) expect(head).toMatch(``) consola.log.mockClear() }) test('/custom (custom layout)', async () => { const { html } = await renderRoute('/custom') expect(html).toMatch('Custom layout') expect(consola.log).toHaveBeenCalledWith('created') expect(consola.log).toHaveBeenCalledWith('mounted') consola.log.mockClear() }) test('/mounted', async () => { const { html } = await renderRoute('/mounted') expect(html).toMatch('