Skip to content

Commit f00b542

Browse files
authored
test: update assertion to allow image cdn responses be webp (#2729)
1 parent 6a2c39c commit f00b542

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

tests/e2e/export.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ test.describe('next/image is using Netlify Image CDN', () => {
6464

6565
expect(nextImageResponse.status()).toBe(200)
6666
// 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')
67+
// source image is jpg, but when requesting it through Image CDN avif or webp will be returned
68+
expect(['image/avif', 'image/webp']).toContain(
69+
await nextImageResponse.headerValue('content-type'),
70+
)
6971

7072
await expectImageWasLoaded(page.locator('img'))
7173
})

tests/e2e/simple-app.test.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ test.describe('next/image is using Netlify Image CDN', () => {
119119

120120
expect(nextImageResponse.status()).toBe(200)
121121
// ensure next/image is using Image CDN
122-
// source image is jpg, but when requesting it through Image CDN avif will be returned
123-
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
122+
// source image is jpg, but when requesting it through Image CDN avif or webp will be returned
123+
expect(['image/avif', 'image/webp']).toContain(
124+
await nextImageResponse.headerValue('content-type'),
125+
)
124126

125127
await expectImageWasLoaded(page.locator('img'))
126128
})
@@ -142,7 +144,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
142144
)
143145

144146
expect(nextImageResponse.status()).toBe(200)
145-
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
147+
expect(['image/avif', 'image/webp']).toContain(
148+
await nextImageResponse.headerValue('content-type'),
149+
)
146150

147151
await expectImageWasLoaded(page.locator('img'))
148152
})
@@ -164,7 +168,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
164168
)
165169

166170
expect(nextImageResponse.status()).toBe(200)
167-
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
171+
expect(['image/avif', 'image/webp']).toContain(
172+
await nextImageResponse.headerValue('content-type'),
173+
)
168174

169175
await expectImageWasLoaded(page.locator('img'))
170176
})
@@ -183,7 +189,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
183189
)
184190

185191
expect(nextImageResponse?.status()).toBe(200)
186-
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
192+
expect(['image/avif', 'image/webp']).toContain(
193+
await nextImageResponse.headerValue('content-type'),
194+
)
187195

188196
await expectImageWasLoaded(page.locator('img'))
189197
})
@@ -203,7 +211,9 @@ test.describe('next/image is using Netlify Image CDN', () => {
203211
)
204212

205213
expect(nextImageResponse.status()).toEqual(200)
206-
expect(await nextImageResponse.headerValue('content-type')).toEqual('image/avif')
214+
expect(['image/avif', 'image/webp']).toContain(
215+
await nextImageResponse.headerValue('content-type'),
216+
)
207217

208218
await expectImageWasLoaded(page.locator('img'))
209219
})

0 commit comments

Comments
 (0)