Skip to content

Commit 3f490f6

Browse files
committed
test: add next/image to static export fixture and test
1 parent 367c396 commit 3f490f6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/e2e/export.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,21 @@ test('Renders the Home page correctly with output export and custom dist dir', a
5252

5353
await expectImageWasLoaded(page.locator('img'))
5454
})
55+
56+
test.describe('next/image is using Netlify Image CDN', () => {
57+
test('Local images', async ({ page, outputExport }) => {
58+
const nextImageResponsePromise = page.waitForResponse('**/_next/image**')
59+
60+
await page.goto(`${outputExport.url}/image/local`)
61+
62+
const nextImageResponse = await nextImageResponsePromise
63+
expect(nextImageResponse.request().url()).toContain('_next/image?url=%2Fsquirrel.jpg')
64+
65+
expect(nextImageResponse.status()).toBe(200)
66+
// ensure next/image is using Image CDN
67+
// source image is jpg, but when requesting it through Image CDN avif will be returned
68+
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
69+
70+
await expectImageWasLoaded(page.locator('img'))
71+
})
72+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Image from 'next/image'
2+
3+
export default function NextImageUsingNetlifyImageCDN() {
4+
return (
5+
<main>
6+
<h1>Next/Image + Netlify Image CDN</h1>
7+
<Image src="/squirrel.jpg" alt="a cute squirrel (next/image)" width={300} height={278} />
8+
</main>
9+
)
10+
}

0 commit comments

Comments
 (0)