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.includes('

My component!

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

mutated

')).toBe(true) }) /* ** 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.includes('color:red')).toBe(true) const element = window.document.querySelector('.red') expect(element).not.toBe(null) expect(element.textContent).toBe('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.includes('background-color:#00f')).toBe(true) // 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.includes('

The answer is 42

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

Vuex Nested Modules

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

1

')).toBe(true) }) 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.includes('

I can haz meta tags

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