mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
test: add open-in-editor and youch test
This commit is contained in:
parent
c7cb0ea562
commit
b7d54b2c75
@ -1,4 +1,4 @@
|
|||||||
import { loadFixture, getPort, Nuxt, Builder } from '../utils'
|
import { loadFixture, getPort, Nuxt, Builder, rp } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -9,6 +9,7 @@ describe('basic dev', () => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const config = loadFixture('basic', {
|
const config = loadFixture('basic', {
|
||||||
dev: true,
|
dev: true,
|
||||||
|
debug: true,
|
||||||
buildDir: '.nuxt-dev',
|
buildDir: '.nuxt-dev',
|
||||||
build: {
|
build: {
|
||||||
stats: 'none'
|
stats: 'none'
|
||||||
@ -47,6 +48,56 @@ describe('basic dev', () => {
|
|||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
test('/__open-in-editor (open-in-editor)', async () => {
|
||||||
|
const { body } = await rp(
|
||||||
|
url('/__open-in-editor?file=pages/index.vue'),
|
||||||
|
{ resolveWithFullResponse: true }
|
||||||
|
)
|
||||||
|
expect(body).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('/__open-in-editor should return error (open-in-editor)', async () => {
|
||||||
|
await expect(rp(url('/__open-in-editor?file='))).rejects.toMatchObject({
|
||||||
|
statusCode: 500,
|
||||||
|
error: 'launch-editor-middleware: required query param "file" is missing.'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('/error should return error stack trace (Youch)', async () => {
|
||||||
|
await expect(nuxt.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
|
||||||
|
statusCode: 500
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test('/error no source-map (Youch)', async () => {
|
||||||
|
const sourceMaps = nuxt.renderer.resources.serverBundle.maps
|
||||||
|
nuxt.renderer.resources.serverBundle.maps = {}
|
||||||
|
|
||||||
|
// const errorSpy = await interceptError()
|
||||||
|
await expect(nuxt.renderAndGetWindow(url('/error'))).rejects.toMatchObject({
|
||||||
|
statusCode: 500
|
||||||
|
})
|
||||||
|
|
||||||
|
nuxt.renderer.resources.serverBundle.maps = sourceMaps
|
||||||
|
})
|
||||||
|
|
||||||
|
test('/error should return json format error (Youch)', async () => {
|
||||||
|
const opts = {
|
||||||
|
headers: {
|
||||||
|
accept: 'application/json'
|
||||||
|
},
|
||||||
|
resolveWithFullResponse: true
|
||||||
|
}
|
||||||
|
await expect(rp(url('/error'), opts)).rejects.toMatchObject({
|
||||||
|
statusCode: 500,
|
||||||
|
response: {
|
||||||
|
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
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await nuxt.close()
|
await nuxt.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user