2021-03-10 11:48:41 +00:00
|
|
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
|
|
|
|
|
|
|
let port
|
|
|
|
let nuxt
|
2023-10-16 21:23:38 +00:00
|
|
|
const url = route => 'http://127.0.0.1:' + port + route
|
2021-03-10 11:48:41 +00:00
|
|
|
|
|
|
|
const tests = [
|
|
|
|
['relative publicPath can be used in dev ssr', {
|
|
|
|
build: {
|
|
|
|
publicPath: './_nuxt/'
|
|
|
|
}
|
|
|
|
}],
|
|
|
|
['relative publicPath can be used in production ssr', {
|
|
|
|
dev: false,
|
|
|
|
build: {
|
|
|
|
publicPath: './_nuxt/'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
]
|
|
|
|
|
|
|
|
describe('basic ssr with relative path', () => {
|
|
|
|
tests.forEach(([name, options]) => test(name, async () => {
|
|
|
|
const config = await loadFixture('basic', options)
|
|
|
|
nuxt = new Nuxt(config)
|
|
|
|
await nuxt.ready()
|
|
|
|
|
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
2021-03-10 11:48:41 +00:00
|
|
|
|
|
|
|
const { html } = await nuxt.server.renderRoute('/')
|
|
|
|
|
|
|
|
expect(html).toContain('<img src="./_nuxt/img')
|
|
|
|
const { 1: imageSrc } = html.match(/<img src="\.(\/_nuxt\/img[^"]*)"/)
|
|
|
|
|
|
|
|
const { statusCode } = await rp(url(imageSrc))
|
|
|
|
expect(statusCode).toBe(200)
|
|
|
|
|
|
|
|
await nuxt.close()
|
|
|
|
}
|
|
|
|
))
|
|
|
|
})
|