Skip to content

Commit beadf65

Browse files
committed
test: add e2e test to test broken image error
1 parent faeabe8 commit beadf65

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cypress/integration/default/images.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,13 @@ describe('next/images', () => {
2626
expect($img[0].naturalWidth, 'image has natural width').to.be.greaterThan(0)
2727
})
2828
})
29+
30+
it('should show throw if an image is not on the domains or remotePatterns allowlist', () => {
31+
cy.request('/broken-image').then((response) => {
32+
expect(response.status).to.eq(500)
33+
expect(response.body).to.include(
34+
'hostname "broken-domain" is not configured under images in your `next.config.js`',
35+
)
36+
})
37+
})
2938
})

demos/default/pages/broken-image.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Image from 'next/legacy/image'
1+
import Image from 'next/image'
22

33
// This should cause an error, because broken-domain is not part of the configured next.config.js image domains
44
const Images = () => (

0 commit comments

Comments
 (0)