2019-02-13 09:18:41 +00:00
|
|
|
import { resolve } from 'path'
|
|
|
|
import { existsSync, readFileSync } from 'fs'
|
|
|
|
import { getPort, loadFixture, Nuxt } from '../utils'
|
|
|
|
|
|
|
|
let port
|
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
|
|
|
|
expect.extend({
|
2019-07-10 10:45:49 +00:00
|
|
|
toFileExist (file) {
|
2019-02-13 09:18:41 +00:00
|
|
|
if (existsSync(file)) {
|
|
|
|
return {
|
|
|
|
message: () => `expected '${file}' not exist`,
|
|
|
|
pass: true
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
message: () => `expected '${file}' exist`,
|
|
|
|
pass: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('build filenames with query part', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const config = await loadFixture('filenames-query-part')
|
|
|
|
nuxt = new Nuxt(config)
|
2019-03-08 20:43:23 +00:00
|
|
|
await nuxt.ready()
|
|
|
|
|
2019-02-13 09:18:41 +00:00
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
2019-02-13 09:18:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('server manifest files exist', () => {
|
|
|
|
const manifest = JSON.parse(readFileSync(resolve(__dirname, '..', 'fixtures/filenames-query-part/.nuxt/dist/server/server.manifest.json'), 'utf8'))
|
|
|
|
expect(manifest).toMatchObject({
|
|
|
|
files: expect.any(Object)
|
|
|
|
})
|
|
|
|
for (const file in manifest.files) {
|
|
|
|
expect(resolve(__dirname, '..', `fixtures/filenames-query-part/.nuxt/dist/server/${manifest.files[file]}`)).toFileExist()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
test("render / without error 'Cannot find module'", async () => {
|
|
|
|
await expect(nuxt.server.renderRoute('/')).resolves.toMatchObject({
|
|
|
|
html: expect.stringContaining('<h1>Chunks with version in query part</h1>')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
})
|