-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathnext-image-https.test.ts
54 lines (45 loc) · 1.43 KB
/
next-image-https.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { nextTestSetup } from 'e2e-utils'
describe('app dir - next-image (with https)', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
startCommand: `pnpm next dev --experimental-https`,
})
if (skipped) {
return
}
if (!process.env.CI) {
console.warn('only runs on CI as it requires administrator privileges')
it('only runs on CI as it requires administrator privileges', () => {})
return
}
it('loads images without any errors', async () => {
let failCount = 0
const browser = await next.browser('/', {
beforePageLoad(page) {
page.on('response', (response) => {
const url = response.url()
if (!url.includes('/_next/image')) return
const status = response.status()
console.log(`URL: ${url} Status: ${status}`)
if (!response.ok()) {
console.log(`Request failed: ${url}`)
failCount++
}
})
},
})
const image = browser.elementByCss('#app-page')
const src = await image.getAttribute('src')
if (process.env.TURBOPACK) {
expect(src).toMatchInlineSnapshot(
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.308c602d.png&w=828&q=90"`
)
} else {
expect(src).toMatchInlineSnapshot(
`"/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.3f1a293b.png&w=828&q=90"`
)
}
expect(failCount).toBe(0)
})
})