Unverified Commit 0e5fb496 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Add test to ensure image generation works in the Node.js runtime (#47719)

Check the test case for more details.
parent 7f063886
import { ImageResponse } from '@vercel/og'
export async function GET() {
return new ImageResponse(<div>hi</div>, {
width: 1200,
height: 630,
})
}
...@@ -38,6 +38,14 @@ describe('og-api', () => { ...@@ -38,6 +38,14 @@ describe('og-api', () => {
expect(body.size).toBeGreaterThan(0) expect(body.size).toBeGreaterThan(0)
}) })
it('should work in app route in node runtime', async () => {
const res = await fetchViaHTTP(next.url, '/og-node')
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('image/png')
const body = await res.blob()
expect(body.size).toBeGreaterThan(0)
})
if ((global as any).isNextStart) { if ((global as any).isNextStart) {
it('should copy files correctly', async () => { it('should copy files correctly', async () => {
expect(next.cliOutput).not.toContain('Failed to copy traced files') expect(next.cliOutput).not.toContain('Failed to copy traced files')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment