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) 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('

Vuex Nested Modules

') expect(html).toContain('

1

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

I can haz meta tags

') expect( html.includes('