Fix tests

This commit is contained in:
Sebastien Chopin 2017-04-14 12:06:40 +02:00
parent ee6db19c8d
commit b49cf4d9d5
3 changed files with 10 additions and 12 deletions

View File

@ -116,12 +116,6 @@ test('/redirect -> check redirected source', async t => {
t.true(html.includes('<h1>Index page</h1>')) t.true(html.includes('<h1>Index page</h1>'))
}) })
test('/error', async t => {
const window = await nuxt.renderAndGetWindow(url('/error'))
const html = window.document.body.innerHTML
t.true(html.includes('Error mouahahah'))
})
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server', t => { test.after('Closing server', t => {
server.close() server.close()

View File

@ -100,10 +100,11 @@ test('/redirect -> check redirected source', async t => {
}) })
test('/error', async t => { test('/error', async t => {
const { html, error } = await nuxt.renderRoute('/error') try {
t.true(html.includes('Error mouahahah')) await nuxt.renderRoute('/error', { req: {}, res: {} })
t.true(error.message.includes('Error mouahahah')) } catch (err) {
t.true(error.statusCode === 500) t.true(err.message.includes('Error mouahahah'))
}
}) })
test('/error status code', async t => { test('/error status code', async t => {

View File

@ -4,8 +4,11 @@
<script> <script>
export default { export default {
asyncData () { asyncData ({ req }) {
// Not for nuxt generate
if (req) {
throw new Error('Error mouahahah') throw new Error('Error mouahahah')
} }
}
} }
</script> </script>