import consola from 'consola' import { loadFixture, getPort, Nuxt, rp } from '../utils' let port const url = route => 'http://localhost:' + port + route let nuxt = null describe('basic ssr', () => { beforeAll(async () => { const options = await loadFixture('basic') nuxt = new Nuxt(options) await nuxt.ready() port = await getPort() await nuxt.server.listen(port, '0.0.0.0') }) test('/stateless', async () => { const { html } = await nuxt.server.renderRoute('/stateless') expect(html).toContain('

My component!

') }) test('/store-module', async () => { const { html } = await nuxt.server.renderRoute('/store-module') expect(html).toContain('

mutated

') }) /* ** Example of testing via dom checking */ test('/css', async () => { const window = await nuxt.server.renderAndGetWindow(url('/css')) const headHtml = window.document.head.innerHTML expect(headHtml).toContain('color:red') const element = window.document.querySelector('.red') expect(element).not.toBe(null) expect(element.textContent).toContain('This is red') expect(element.className).toBe('red') // t.is(window.getComputedStyle(element).color, 'red') }) test('/postcss', async () => { const window = await nuxt.server.renderAndGetWindow(url('/css')) const headHtml = window.document.head.innerHTML expect(headHtml).toContain('color:red') const element = window.document.querySelector('.red') expect(element).not.toBe(null) expect(element.textContent).toContain('This is red') expect(element.className).toBe('red') // t.is(window.getComputedStyle(element).color, 'red') }) test('/postcss', async () => { const window = await nuxt.server.renderAndGetWindow(url('/css')) const headHtml = window.document.head.innerHTML expect(headHtml).toContain('background-color:#00f') // const element = window.document.querySelector('div.red') // t.is(window.getComputedStyle(element)['background-color'], 'blue') }) test('/stateful', async () => { const { html } = await nuxt.server.renderRoute('/stateful') expect(html).toContain('

The answer is 42

') }) test('/store', async () => { const { html } = await nuxt.server.renderRoute('/store') expect(html).toContain('

foo/bar/baz: Vuex Nested Modules

') expect(html).toContain('

index/counter: 1

') expect(html).toContain('

foo/blarg/getVal: 4

') expect(html).toContain('

foo/bab/getBabVal: 10

') }) test('/head', async () => { const window = await nuxt.server.renderAndGetWindow(url('/head')) expect(window.document.title).toBe('My title - Nuxt') const html = window.document.querySelector('html').outerHTML expect(html).toContain('

I can haz meta tags

') expect(html).toContain('