Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: ssr log #6596

Merged
merged 1 commit into from Oct 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions test/unit/basic.dev.test.js
@@ -1,4 +1,5 @@
import path from 'path'
import jsdom from 'jsdom'
import consola from 'consola'
import { Builder, BundleBuilder, getPort, loadFixture, Nuxt, rp, waitFor } from '../utils'

Expand Down Expand Up @@ -51,6 +52,14 @@ describe('basic dev', () => {
postcssLoader = cssLoaders[cssLoaders.length - 1]
}
}
},
hooks: {
'vue-renderer:ssr:context': ({ nuxt }) => {
nuxt.logs = [{ type: 'log', args: ['This is a test ssr log'] }]
}
},
render: {
ssrLog: 'collapsed'
}
})

Expand Down Expand Up @@ -169,6 +178,27 @@ describe('basic dev', () => {
})
})

test('/ should display ssr log in collapsed group', async () => {
const virtualConsole = new jsdom.VirtualConsole()
const groupCollapsed = jest.fn()
const groupEnd = jest.fn()
const log = jest.fn()
virtualConsole.on('groupCollapsed', groupCollapsed)
virtualConsole.on('groupEnd', groupEnd)
virtualConsole.on('log', log)

await nuxt.server.renderAndGetWindow(url('/'), {
virtualConsole
})

expect(groupCollapsed).toHaveBeenCalledWith(
'%cNuxt SSR',
'background: #2E495E;border-radius: 0.5em;color: white;font-weight: bold;padding: 2px 0.5em;'
)
expect(groupEnd).toHaveBeenCalled()
expect(log).toHaveBeenCalledWith('This is a test ssr log')
})

// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
Expand Down