mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// import rp from 'request-promise-native'
|
|
import { Nuxt } from '../../'
|
|
import { loadFixture, getPort } from '../utils'
|
|
|
|
let port
|
|
const url = route => 'http://localhost:' + port + route
|
|
|
|
let nuxt = null
|
|
// let logSpy
|
|
|
|
describe('error', () => {
|
|
beforeAll(async () => {
|
|
const config = loadFixture('error')
|
|
nuxt = new Nuxt(config)
|
|
port = await getPort()
|
|
await nuxt.listen(port, 'localhost')
|
|
})
|
|
|
|
test('/ should display an error', async () => {
|
|
await expect(nuxt.renderRoute('/')).rejects.toMatchObject({
|
|
message: expect.stringContaining('not_defined is not defined')
|
|
})
|
|
})
|
|
|
|
test('/404 should display an error too', async () => {
|
|
let { error } = await nuxt.renderRoute('/404')
|
|
expect(error.message.includes('This page could not be found')).toBe(true)
|
|
})
|
|
|
|
test('/ with renderAndGetWindow()', async () => {
|
|
// const errorSpy = await interceptError()
|
|
await expect(nuxt.renderAndGetWindow(url('/'))).rejects.toMatchObject({
|
|
statusCode: 500
|
|
})
|
|
})
|
|
|
|
test('Error: resolvePath()', async () => {
|
|
expect(() => nuxt.resolvePath()).toThrowError('The \'request\' argument must be string')
|
|
expect(() => nuxt.resolvePath('@/pages/about.vue')).toThrowError('Cannot resolve "@/pages/about.vue"')
|
|
})
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
test('Closing server and nuxt.js', async () => {
|
|
await nuxt.close()
|
|
})
|
|
})
|