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>'))
})
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
test.after('Closing server', t => {
server.close()

View File

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

View File

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