mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
test: request of error accepts JSON
This commit is contained in:
parent
2c52a8bc5a
commit
4cafca0fec
@ -38,6 +38,17 @@ test('/test/error should return error stack trace (Youch)', async t => {
|
|||||||
t.true(error.includes('<div class="error-frames">'))
|
t.true(error.includes('<div class="error-frames">'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('/test/error should return json format error (Youch)', async t => {
|
||||||
|
const opts = {
|
||||||
|
headers: {
|
||||||
|
'accept': 'application/json'
|
||||||
|
},
|
||||||
|
resolveWithFullResponse: true
|
||||||
|
}
|
||||||
|
const { response: { headers } } = await t.throws(rp(url('/test/error'), opts))
|
||||||
|
t.is(headers['content-type'], 'text/json; charset=utf-8')
|
||||||
|
})
|
||||||
|
|
||||||
// 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 and nuxt.js', t => {
|
test.after('Closing server and nuxt.js', t => {
|
||||||
nuxt.close()
|
nuxt.close()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt, Builder } from '../index.js'
|
import { Nuxt, Builder } from '../index.js'
|
||||||
|
|
||||||
const port = 4005
|
const port = 4005
|
||||||
@ -38,6 +39,17 @@ test('/ with renderAndGetWindow()', async t => {
|
|||||||
t.is(err.response.statusMessage, 'NuxtServerError')
|
t.is(err.response.statusMessage, 'NuxtServerError')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('/ with text/json content', async t => {
|
||||||
|
const opts = {
|
||||||
|
headers: {
|
||||||
|
'accept': 'application/json'
|
||||||
|
},
|
||||||
|
resolveWithFullResponse: true
|
||||||
|
}
|
||||||
|
const { response: { headers } } = await t.throws(rp(url('/'), opts))
|
||||||
|
t.is(headers['content-type'], 'text/json; charset=utf-8')
|
||||||
|
})
|
||||||
|
|
||||||
// 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 and nuxt.js', t => {
|
test.after('Closing server and nuxt.js', t => {
|
||||||
nuxt.close()
|
nuxt.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user