Files
Shu DingandGitHub dc57cde301 Update @vercel/og and satori vendors (#90933)
The new `@vercel/og` and `satori` include many improvements:
- 2~20x faster image generation (`ImageResponse` API) by using Sharp for
rasterization, and optimized Satori core
- Better CSS/SVG coverage:
  - https://github.com/vercel/satori/issues/736
  - https://github.com/vercel/satori/pull/734
  - https://github.com/vercel/satori/pull/733
  - https://github.com/vercel/satori/pull/732
  - https://github.com/vercel/satori/issues/728
  - https://github.com/vercel/satori/issues/724
  - https://github.com/vercel/satori/pull/717
  - https://github.com/vercel/satori/pull/718
  - https://github.com/vercel/satori/pull/719
- Updated layout engine (https://github.com/vercel/satori/pull/689):
  - Support for `box-sizing`
  - Support for `display: contents`
  - Support for `position: static`
  - Support for `align-content: space-evenly`
  - Better support for `position: absolute`
  - Support for percentage values for `gap`
- Noto Sans → Geist Sans
2026-03-05 18:26:21 +00:00

66 lines
2.3 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import imageSize from 'image-size'
import path from 'path'
describe('app dir - Metadata API on the Edge runtime', () => {
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
describe('OG image route', () => {
if (isNextStart) {
it('should not bundle `ImageResponse` into the page worker', async () => {
const middlewareManifest = JSON.parse(
await next.readFile('.next/server/middleware-manifest.json')
)
const uniquePageFiles = [
...new Set<string>(middlewareManifest.functions['/page'].files),
]
const pageFilesThatHaveImageResponse = uniquePageFiles.filter(
(file) => {
return next
.readFileSync(path.join('.next', file))
.includes('loadAdditionalAsset')
}
)
expect(pageFilesThatHaveImageResponse).not.toBeEmpty()
const uniqueAnotherFiles = [
...new Set<string>(
middlewareManifest.functions['/another/page'].files
),
]
expect(uniqueAnotherFiles).not.toBeEmpty()
const anotherFilesThatHaveImageResponse = uniqueAnotherFiles.filter(
(file) => {
return (
next
.readFileSync(path.join('.next', file))
// It checks if the `@vercel/og` package is shared between the two routes.
.includes('loadAdditionalAsset')
)
}
)
// Grab the list of files that hold `ImageResponse`. Given the chunking should create the same file for both routes it should end up being the same object.
// This test was added to ensure that we don't include `ImageResponse` in the individual page bundles: https://github.com/vercel/next.js/pull/51950.
expect(pageFilesThatHaveImageResponse).toMatchObject(
anotherFilesThatHaveImageResponse
)
})
}
})
it('should render OpenGraph image meta tag correctly', async () => {
const html$ = await next.render$('/')
const ogUrl = new URL(html$('meta[property="og:image"]').attr('content'))
const imageBuffer = await (await next.fetch(ogUrl.pathname)).buffer()
const size = imageSize(imageBuffer)
expect([size.width, size.height]).toEqual([1200, 630])
})
})