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.listen(port, '0.0.0.0') }) test('/stateless', async () => { const { html } = await nuxt.renderRoute('/stateless') expect(html.includes('

My component!

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

mutated

')).toBe(true) }) /* ** Example of testing via dom checking */ test('/css', async () => { const window = await nuxt.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.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.renderRoute('/stateful') expect(html.includes('

The answer is 42

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

Vuex Nested Modules

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

1

')).toBe(true) }) test('/head', async () => { const window = await nuxt.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('