mirror of https://github.com/sundowndev/http.git
48 lines
833 B
JavaScript
48 lines
833 B
JavaScript
const { Nuxt, Builder } = require('nuxt-edge')
|
|
|
|
const defaultConfig = require('./fixture/nuxt.config')
|
|
|
|
jest.setTimeout(60000)
|
|
|
|
async function setupMockNuxt(config) {
|
|
const nuxt = new Nuxt({
|
|
...defaultConfig,
|
|
...config,
|
|
_ready: false
|
|
})
|
|
|
|
nuxt.moduleContainer.addTemplate = jest.fn(nuxt.moduleContainer.addTemplate)
|
|
|
|
await nuxt.ready()
|
|
|
|
const builder = new Builder(nuxt)
|
|
|
|
await builder.validatePages()
|
|
await builder.generateRoutesAndFiles()
|
|
nuxt.builder = builder
|
|
|
|
return nuxt
|
|
}
|
|
|
|
async function setupNuxt(config) {
|
|
const nuxt = new Nuxt({
|
|
...defaultConfig,
|
|
...config,
|
|
_ready: false
|
|
})
|
|
|
|
jest.spyOn(nuxt.moduleContainer, 'addTemplate')
|
|
|
|
await nuxt.ready()
|
|
|
|
const builder = new Builder(nuxt)
|
|
nuxt.builder = builder
|
|
|
|
return nuxt
|
|
}
|
|
|
|
module.exports = {
|
|
setupMockNuxt,
|
|
setupNuxt
|
|
}
|