[READ-ONLY] Mirror of https://github.com/danielroe/cross-origin-storage. Load shared dependencies from Cross-Origin Storage (COS).
cross-origin-storage
experimental
nuxt
vite
vite-plugin
1import { fileURLToPath } from 'node:url'
2import { describe, expect, it } from 'vitest'
3import { $fetch, setup } from '@nuxt/test-utils/e2e'
4
5describe('ssr', async () => {
6 await setup({
7 rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
8 build: true,
9 })
10
11 it('renders the server-rendered markup', async () => {
12 const html = await $fetch('/')
13 expect(html).toContain('count: 0')
14 })
15
16 it('injects the cos loader and removes the default entry script', async () => {
17 const html = await $fetch('/')
18 expect(html).toContain('<script id="cos-loader">')
19 expect(html).toMatch(/cos1:[a-f0-9]{64}/)
20 expect(html).not.toMatch(/<script type="module"[^>]*src="\/_nuxt\/[^"]*"/)
21 })
22
23 it('inlines a manifest whose entry resolves to a managed chunk', async () => {
24 const html = await $fetch('/')
25 const entry = html.match(/"entry":"(cos1:[a-f0-9]{64})"/)?.[1]
26 expect(entry).toBeDefined()
27 const chunks = html.match(/"chunks":\{(.+?)\}\}\)/)?.[1] ?? ''
28 expect(chunks).toContain(`"${entry}":`)
29 })
30})