mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-29 23:02:42 +00:00
basic tests for express middleware
This commit is contained in:
parent
6639b9a411
commit
b16060afd4
@ -139,6 +139,7 @@
|
|||||||
"eslint-plugin-node": "^5.1.1",
|
"eslint-plugin-node": "^5.1.1",
|
||||||
"eslint-plugin-promise": "^3.5.0",
|
"eslint-plugin-promise": "^3.5.0",
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
|
"express": "^4.15.3",
|
||||||
"finalhandler": "^1.0.3",
|
"finalhandler": "^1.0.3",
|
||||||
"jsdom": "^11.1.0",
|
"jsdom": "^11.1.0",
|
||||||
"json-loader": "^0.5.6",
|
"json-loader": "^0.5.6",
|
||||||
|
41
test/express.test.js
Normal file
41
test/express.test.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import test from 'ava'
|
||||||
|
import { resolve } from 'path'
|
||||||
|
import { Nuxt, Builder } from '../index.js'
|
||||||
|
import express from 'express'
|
||||||
|
import rp from 'request-promise-native'
|
||||||
|
|
||||||
|
const port = 4000
|
||||||
|
const url = (route) => 'http://localhost:' + port + route
|
||||||
|
|
||||||
|
let nuxt
|
||||||
|
let app
|
||||||
|
|
||||||
|
// Init nuxt.js and create express server
|
||||||
|
test.before('Init Nuxt.js', async t => {
|
||||||
|
const options = {
|
||||||
|
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||||
|
dev: false,
|
||||||
|
runBuild: true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create nuxt instace
|
||||||
|
nuxt = new Nuxt(options)
|
||||||
|
|
||||||
|
// Build
|
||||||
|
await new Builder(nuxt).build()
|
||||||
|
|
||||||
|
// Create express app
|
||||||
|
app = express()
|
||||||
|
|
||||||
|
// Register nuxt
|
||||||
|
app.use(nuxt.render)
|
||||||
|
|
||||||
|
// Start listening on localhost:4000
|
||||||
|
app.listen(port)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('/stateless with express', async t => {
|
||||||
|
const html = await rp(url('/stateless'))
|
||||||
|
|
||||||
|
t.true(html.includes('<h1>My component!</h1>'))
|
||||||
|
})
|
@ -2588,7 +2588,7 @@ expand-range@^1.8.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fill-range "^2.1.0"
|
fill-range "^2.1.0"
|
||||||
|
|
||||||
express@^4.15.2:
|
express@^4.15.2, express@^4.15.3:
|
||||||
version "4.15.3"
|
version "4.15.3"
|
||||||
resolved "https://registry.yarnpkg.com/express/-/express-4.15.3.tgz#bab65d0f03aa80c358408972fc700f916944b662"
|
resolved "https://registry.yarnpkg.com/express/-/express-4.15.3.tgz#bab65d0f03aa80c358408972fc700f916944b662"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Loading…
Reference in New Issue
Block a user