mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
Fix tests
This commit is contained in:
parent
840a6cfe00
commit
c26daa9e8f
@ -1,7 +1,7 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4001
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -16,7 +16,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
dev: true
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
@ -37,8 +37,7 @@ test('/_nuxt/test.hot-update.json should returns empty html', async t => {
|
||||
})
|
||||
|
||||
// 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', async t => {
|
||||
server.close()
|
||||
nuxt.close(() => {
|
||||
})
|
||||
await nuxt.close(() => {})
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import { Nuxt } from '../index.js'
|
||||
import { Nuxt, Builder, Generator } from '../index.js'
|
||||
|
||||
test('Fail with routes() which throw an error', async t => {
|
||||
const options = {
|
||||
@ -14,7 +14,9 @@ test('Fail with routes() which throw an error', async t => {
|
||||
}
|
||||
}
|
||||
const nuxt = new Nuxt(options)
|
||||
return nuxt.generate()
|
||||
const builder = new Builder(nuxt)
|
||||
const generator = new Generator(nuxt, builder)
|
||||
return generator.generate()
|
||||
.catch((e) => {
|
||||
t.true(e.message === 'Not today!')
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ import http from 'http'
|
||||
import serveStatic from 'serve-static'
|
||||
import finalhandler from 'finalhandler'
|
||||
import rp from 'request-promise-native'
|
||||
import { Nuxt } from '../index.js'
|
||||
import { Nuxt, Builder, Generator } from '../index.js'
|
||||
|
||||
const port = 4002
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -20,8 +20,10 @@ test.before('Init Nuxt.js', async t => {
|
||||
config.dev = false
|
||||
config.runBuild = true
|
||||
nuxt = new Nuxt(config)
|
||||
const builder = new Builder(nuxt)
|
||||
const generator = new Generator(nuxt, builder)
|
||||
try {
|
||||
await nuxt.generate() // throw an error (of /validate route)
|
||||
await generator.generate() // throw an error (of /validate route)
|
||||
} catch (err) {
|
||||
}
|
||||
const serve = serveStatic(resolve(__dirname, 'fixtures/basic/dist'))
|
||||
|
@ -2,7 +2,7 @@ import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import stdMocks from 'std-mocks'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4003
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -18,7 +18,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
runBuild: true
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4004
|
||||
// const url = (route) => 'http://localhost:' + port + route
|
||||
@ -16,7 +16,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
runBuild: true
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
|
@ -2,7 +2,7 @@ import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import fs from 'fs'
|
||||
import pify from 'pify'
|
||||
import { Nuxt } from '../index.js'
|
||||
import { Nuxt, Builder } from '../index.js'
|
||||
|
||||
const readFile = pify(fs.readFile)
|
||||
|
||||
@ -12,7 +12,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
dev: false,
|
||||
runBuild: true
|
||||
})
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
})
|
||||
|
||||
test('Check .nuxt/router.js', t => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4005
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -16,7 +16,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
runBuild: true
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import { Nuxt } from '../index.js'
|
||||
import { Nuxt, Builder } from '../index.js'
|
||||
|
||||
test('Nuxt.js Class', t => {
|
||||
t.is(typeof Nuxt, 'function')
|
||||
@ -12,7 +12,6 @@ test.serial('Nuxt.js Instance', async t => {
|
||||
})
|
||||
t.is(typeof nuxt, 'object')
|
||||
t.is(nuxt.options.dev, true)
|
||||
t.is(typeof nuxt.generate, 'function')
|
||||
t.is(typeof nuxt._ready.then, 'function')
|
||||
await nuxt.ready()
|
||||
t.is(nuxt.initialized, true)
|
||||
@ -24,7 +23,7 @@ test.serial('Fail to build when no pages/ directory but is in the parent', t =>
|
||||
runBuild: true,
|
||||
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
|
||||
})
|
||||
return nuxt.ready().catch(err => {
|
||||
return new Builder(nuxt).build().catch(err => {
|
||||
let s = String(err)
|
||||
t.true(s.includes('No `pages` directory found'))
|
||||
t.true(s.includes('Did you mean to run `nuxt` in the parent (`../`) directory?'))
|
||||
@ -37,7 +36,7 @@ test.serial('Fail to build when no pages/ directory', t => {
|
||||
runBuild: true,
|
||||
rootDir: resolve(__dirname)
|
||||
})
|
||||
return nuxt.ready().catch(err => {
|
||||
return new Builder(nuxt).build().catch(err => {
|
||||
let s = String(err)
|
||||
t.true(s.includes('Couldn\'t find a `pages` directory'))
|
||||
t.true(s.includes('Please create one under the project root'))
|
||||
|
@ -1,7 +1,7 @@
|
||||
import test from 'ava'
|
||||
import { resolve, normalize } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4006
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -17,7 +17,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
config.dev = false
|
||||
config.runBuild = true
|
||||
nuxt = new Nuxt(config)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import { Nuxt, Server } from '../index.js'
|
||||
import { Nuxt, Server, Builder } from '../index.js'
|
||||
|
||||
const port = 4007
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
@ -17,7 +17,7 @@ test.before('Init Nuxt.js', async t => {
|
||||
config.dev = false
|
||||
config.runBuild = true
|
||||
nuxt = new Nuxt(config)
|
||||
await nuxt.ready()
|
||||
await new Builder(nuxt).build()
|
||||
server = new Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
@ -104,13 +104,3 @@ test.after('Closing server and nuxt.js', t => {
|
||||
server.close()
|
||||
nuxt.close()
|
||||
})
|
||||
|
||||
test.after('Should be able to start Nuxt with build done', async t => {
|
||||
const rootDir = resolve(__dirname, 'fixtures/with-config')
|
||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
config.runBuild = true
|
||||
nuxt = new Nuxt(config)
|
||||
await nuxt.ready()
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user