import http from 'http' import { join, resolve } from 'upath' import serveStatic from 'serve-static' import finalhandler from 'finalhandler' import glob from 'glob' import { Builder, Generator, getPort, loadFixture, Nuxt, rp } from '../utils' let port const url = route => 'http://127.0.0.1:' + port + route const rootDir = resolve(__dirname, '..', 'fixtures/full-static') const distDir = resolve(rootDir, '.nuxt-generate') let builder let server = null let generator = null const generateAndStartServer = async (overrides) => { const config = await loadFixture('full-static', { generate: { static: false, dir: '.nuxt-generate' }, ...(overrides || {}) }) const nuxt = new Nuxt(config) await nuxt.ready() builder = new Builder(nuxt) builder.build = jest.fn() generator = new Generator(nuxt, builder) await generator.generate() const serve = serveStatic(distDir) server = http.createServer((req, res) => { serve(req, res, finalhandler(req, res)) }) port = await getPort() server.listen(port) } describe('full-static', () => { describe('with scripts', () => { beforeAll(async () => await generateAndStartServer()) test('/payload (custom build.publicPath)', async () => { const { body: html } = await rp(url('/payload')) expect(html).toContain('