mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix tests
This commit is contained in:
parent
8391f308b7
commit
56c39bea88
10
lib/build.js
10
lib/build.js
@ -43,6 +43,10 @@ let webpackStats = 'none'
|
||||
// force green color
|
||||
debug.color = 2
|
||||
|
||||
// temporary fix for vuejs/vue#5540 until new vue server renderer release
|
||||
const uniq = require('lodash').uniq
|
||||
const fixClientManifest = manifest => Object.assign(manifest, {initial: uniq(manifest.initial)})
|
||||
|
||||
const defaults = {
|
||||
analyze: false,
|
||||
publicPath: '/_nuxt/',
|
||||
@ -105,7 +109,7 @@ export function options () {
|
||||
if (fs.existsSync(bundlePath) && fs.existsSync(manifestPath)) {
|
||||
const bundle = fs.readFileSync(bundlePath, 'utf8')
|
||||
const manifest = fs.readFileSync(manifestPath, 'utf8')
|
||||
createRenderer.call(this, JSON.parse(bundle), JSON.parse(manifest))
|
||||
createRenderer.call(this, JSON.parse(bundle), fixClientManifest(JSON.parse(manifest)))
|
||||
addAppTemplate.call(this)
|
||||
}
|
||||
}
|
||||
@ -431,7 +435,7 @@ function webpackWatchAndUpdate () {
|
||||
} else {
|
||||
const bundle = serverFS.readFileSync(bundlePath, 'utf8')
|
||||
const manifest = clientFS.readFileSync(manifestPath, 'utf8')
|
||||
createRenderer.call(this, JSON.parse(bundle), JSON.parse(manifest))
|
||||
createRenderer.call(this, JSON.parse(bundle), fixClientManifest(JSON.parse(manifest)))
|
||||
}
|
||||
}
|
||||
this.watchHandler = watchHandler
|
||||
@ -464,7 +468,7 @@ function webpackRunServer () {
|
||||
readFile(bundlePath, 'utf8')
|
||||
.then((bundle) => readFile(manifestPath, 'utf8')
|
||||
.then(manifest => {
|
||||
createRenderer.call(this, JSON.parse(bundle), JSON.parse(manifest))
|
||||
createRenderer.call(this, JSON.parse(bundle), fixClientManifest(JSON.parse(manifest)))
|
||||
resolve()
|
||||
}))
|
||||
})
|
||||
|
@ -128,7 +128,8 @@ export function renderAndGetWindow (url, opts = {}) {
|
||||
/* istanbul ignore if */
|
||||
if (!jsdom) {
|
||||
try {
|
||||
jsdom = require('jsdom')
|
||||
// https://github.com/tmpvar/jsdom/blob/master/lib/old-api.md
|
||||
jsdom = require('jsdom/lib/old-api')
|
||||
} catch (e) {
|
||||
console.error('Fail when calling nuxt.renderAndGetWindow(url)') // eslint-disable-line no-console
|
||||
console.error('jsdom module is not installed') // eslint-disable-line no-console
|
||||
@ -136,13 +137,14 @@ export function renderAndGetWindow (url, opts = {}) {
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
let virtualConsole = new jsdom.VirtualConsole().sendTo(console)
|
||||
let virtualConsole = jsdom.createVirtualConsole().sendTo(console)
|
||||
// let virtualConsole = new jsdom.VirtualConsole().sendTo(console)
|
||||
if (opts.virtualConsole === false) {
|
||||
virtualConsole = undefined
|
||||
}
|
||||
url = url || 'http://localhost:3000'
|
||||
return new Promise((resolve, reject) => {
|
||||
jsdom.env({
|
||||
return jsdom.env({
|
||||
url: url,
|
||||
features: {
|
||||
FetchExternalResources: ['script', 'link'],
|
||||
|
@ -17,12 +17,11 @@ test.before('Init Nuxt.js', async t => {
|
||||
test('Check .nuxt/router.js', t => {
|
||||
return readFile(resolve(__dirname, './fixtures/dynamic-routes/.nuxt/router.js'), 'utf-8')
|
||||
.then((routerFile) => {
|
||||
routerFile = routerFile.slice(
|
||||
routerFile.indexOf('routes: ['),
|
||||
-3
|
||||
)
|
||||
.replace('routes: [', '[')
|
||||
.replace(/ _[0-9A-z]+,/g, ' "",')
|
||||
routerFile = routerFile
|
||||
.slice(routerFile.indexOf('routes: ['))
|
||||
.replace('routes: [', '[')
|
||||
.replace(/ _[0-9A-z]+,/g, ' "",')
|
||||
.replace('})', '')
|
||||
let routes = eval('( ' + routerFile + ')') // eslint-disable-line no-eval
|
||||
// pages/index.vue
|
||||
t.is(routes[0].path, '/')
|
||||
|
Loading…
Reference in New Issue
Block a user