diff --git a/test/debug.test.js b/test/debug.test.js index 189721bc16..ee9ad758c5 100644 --- a/test/debug.test.js +++ b/test/debug.test.js @@ -38,6 +38,17 @@ test('/test/error should return error stack trace (Youch)', async t => { t.true(error.includes('
')) }) +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 test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/error.test.js b/test/error.test.js index 96bea41a2f..c5f55469ec 100644 --- a/test/error.test.js +++ b/test/error.test.js @@ -1,5 +1,6 @@ import test from 'ava' import { resolve } from 'path' +import rp from 'request-promise-native' import { Nuxt, Builder } from '../index.js' const port = 4005 @@ -38,6 +39,17 @@ test('/ with renderAndGetWindow()', async t => { 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 test.after('Closing server and nuxt.js', t => { nuxt.close()