mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
36 lines
989 B
TypeScript
36 lines
989 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('app-dir absolute assetPrefix', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
nextConfig: {
|
|
assetPrefix: 'https://example.vercel.sh/',
|
|
},
|
|
})
|
|
|
|
it('bundles should return 200 on served assetPrefix', async () => {
|
|
const $ = await next.render$('/')
|
|
|
|
let bundles = []
|
|
for (const script of $('script').toArray()) {
|
|
const { src } = script.attribs
|
|
if (
|
|
src?.includes('https://example.vercel.sh/_next/static') ||
|
|
src?.includes('https://example.vercel.sh/_next/static/immutable')
|
|
) {
|
|
bundles.push(src)
|
|
}
|
|
}
|
|
|
|
expect(bundles.length).toBeGreaterThan(0)
|
|
|
|
for (const src of bundles) {
|
|
// Remove hostname to check if pathname is still used for serving the bundles
|
|
const bundlePathWithoutHost = decodeURI(new URL(src).href)
|
|
const { status } = await next.fetch(bundlePathWithoutHost)
|
|
|
|
expect(status).toBe(200)
|
|
}
|
|
})
|
|
})
|