Skip to content

Commit

Permalink
test: ssr log (#6596)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and pi0 committed Oct 21, 2019
1 parent 92405b3 commit 9276c09
Showing 1 changed file with 30 additions and 0 deletions.
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

0 comments on commit 9276c09

Please sign in to comment.