import consola from 'consola' import { loadFixture, getPort, Nuxt, rp } from '../utils' let nuxt, port, options const url = route => 'http://localhost:' + port + route const modernUA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' const modernInfo = mode => `Modern bundles are detected. Modern mode (\`${mode}\`) is enabled now.` describe('modern client mode (SPA)', () => { beforeAll(async () => { options = await loadFixture('modern', { render: { ssr: false } }) nuxt = new Nuxt(options) await nuxt.ready() port = await getPort() await nuxt.server.listen(port, 'localhost') }) test('should detect client modern mode', async () => { await nuxt.server.renderAndGetWindow(url('/')) expect(consola.info).toHaveBeenCalledWith(modernInfo('client')) }) test('should contain nomodule legacy resources', async () => { const { body: response } = await rp(url('/')) expect(response).toContain('src="/_nuxt/app.js" crossorigin="use-credentials" nomodule') expect(response).toContain('src="/_nuxt/vendors/commons.js" crossorigin="use-credentials" nomodule') }) test('should contain module modern resources', async () => { const { body: response } = await rp(url('/')) expect(response).toContain('