2020-06-30 17:47:42 +00:00
|
|
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
2018-11-07 23:37:06 +00:00
|
|
|
|
|
|
|
let nuxt, port
|
2023-10-16 21:23:38 +00:00
|
|
|
const url = route => 'http://127.0.0.1:' + port + route
|
2018-11-07 23:37:06 +00:00
|
|
|
|
2018-11-26 22:49:47 +00:00
|
|
|
describe('modern client mode (SSR)', () => {
|
2018-11-07 23:37:06 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
const options = await loadFixture('modern', { modern: 'client' })
|
|
|
|
nuxt = new Nuxt(options)
|
2019-03-08 20:43:23 +00:00
|
|
|
await nuxt.ready()
|
|
|
|
|
2018-11-07 23:37:06 +00:00
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
2018-11-07 23:37:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain nomodule legacy resources', async () => {
|
2019-12-02 15:23:56 +00:00
|
|
|
const { body: response } = await rp(url('/'))
|
2018-12-05 16:21:58 +00:00
|
|
|
expect(response).toContain('script nomodule crossorigin="use-credentials" src="/_nuxt/app.js')
|
2020-09-09 08:49:31 +00:00
|
|
|
expect(response).toContain('script nomodule crossorigin="use-credentials" src="/_nuxt/commons/app.js')
|
2018-11-07 23:37:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain module modern resources', async () => {
|
2019-12-02 15:23:56 +00:00
|
|
|
const { body: response } = await rp(url('/'))
|
2020-06-30 17:47:42 +00:00
|
|
|
expect(response).toContain('<script type="module" crossorigin="use-credentials" src="/_nuxt/app.modern.js"')
|
2020-09-09 08:49:31 +00:00
|
|
|
expect(response).toContain('<script type="module" crossorigin="use-credentials" src="/_nuxt/commons/app.modern.js"')
|
2018-11-07 23:37:06 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain module preload resources', async () => {
|
2019-12-02 15:23:56 +00:00
|
|
|
const { body: response } = await rp(url('/'))
|
2020-06-30 17:47:42 +00:00
|
|
|
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/app.modern.js" as="script">')
|
2020-09-09 08:49:31 +00:00
|
|
|
expect(response).toContain('<link rel="modulepreload" crossorigin="use-credentials" href="/_nuxt/commons/app.modern.js" as="script">')
|
2018-11-07 23:37:06 +00:00
|
|
|
})
|
|
|
|
|
2018-11-26 12:09:30 +00:00
|
|
|
test('should contain module http2 pushed resources', async () => {
|
2019-12-02 15:23:56 +00:00
|
|
|
const { headers: { link } } = await rp(url('/'))
|
2018-11-26 12:09:30 +00:00
|
|
|
expect(link).toEqual([
|
2020-06-30 17:47:42 +00:00
|
|
|
'</_nuxt/runtime.modern.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
|
2020-09-09 08:49:31 +00:00
|
|
|
'</_nuxt/commons/app.modern.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
|
2020-06-30 17:47:42 +00:00
|
|
|
'</_nuxt/app.modern.js>; rel=modulepreload; crossorigin=use-credentials; as=script',
|
|
|
|
`</_nuxt/pages/index.modern.js>; rel=modulepreload; crossorigin=use-credentials; as=script`
|
2018-11-26 12:09:30 +00:00
|
|
|
].join(', '))
|
|
|
|
})
|
|
|
|
|
2019-01-08 13:20:48 +00:00
|
|
|
test('should contain safari fix script', async () => {
|
2019-12-02 15:23:56 +00:00
|
|
|
const { body: response } = await rp(url('/'))
|
2019-01-08 13:20:48 +00:00
|
|
|
expect(response).toContain('"noModule"')
|
|
|
|
})
|
|
|
|
|
2018-11-07 23:37:06 +00:00
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
})
|