Skip to content

Commit 196e347

Browse files
committed
add tests
1 parent 4546f6d commit 196e347

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/integration/image-component/default/test/index.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ const nextConfig = join(appDir, 'next.config.js')
2222
let appPort
2323
let app
2424

25+
async function hasImageMatchingUrl(browser, url) {
26+
const links = await browser.elementsByCss('img')
27+
let foundMatch = false
28+
for (const link of links) {
29+
const src = await link.getAttribute('src')
30+
if (src === url) {
31+
foundMatch = true
32+
break
33+
}
34+
}
35+
return foundMatch
36+
}
37+
2538
function runTests(mode) {
2639
it('should load the images', async () => {
2740
let browser
@@ -54,6 +67,16 @@ function runTests(mode) {
5467

5568
return 'result-correct'
5669
}, /result-correct/)
70+
71+
expect(
72+
await hasImageMatchingUrl(
73+
browser,
74+
mode === 'serverless'
75+
? // FIXME: this is a bug
76+
`http://localhost:${appPort}/_next/image/?url=%2Ftest.jpg&w=420&q=75`
77+
: `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=420&q=75`
78+
)
79+
).toBe(true)
5780
} finally {
5881
if (browser) {
5982
await browser.close()

0 commit comments

Comments
 (0)