import test from 'ava' import { resolve, normalize } from 'path' import rp from 'request-promise-native' import { Nuxt, Builder } from '..' import { intercept } from './helpers/console' const port = 4006 const url = route => 'http://localhost:' + port + route let nuxt = null let builder = null let buildSpies = null // Init nuxt.js and create server listening on localhost:4000 test.serial('Init Nuxt.js', async t => { const rootDir = resolve(__dirname, 'fixtures/module') const config = require(resolve(rootDir, 'nuxt.config.js')) config.rootDir = rootDir config.dev = false nuxt = new Nuxt(config) builder = new Builder(nuxt) buildSpies = await intercept({ log: true, error: true }, async () => { await builder.build() await nuxt.listen(port, 'localhost') }) t.true(buildSpies.log.calledWithMatch('DONE')) t.true(buildSpies.log.calledWithMatch('OPEN')) }) test.serial('Vendor', async t => { t.true( nuxt.options.build.vendor.indexOf('lodash') !== -1, 'lodash added to config' ) }) test.serial('Plugin', async t => { t.true( normalize(nuxt.options.plugins[0].src).includes( normalize('fixtures/module/.nuxt/basic.reverse.') ), 'plugin added to config' ) const { html } = await nuxt.renderRoute('/') t.true(html.includes('