Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Sep 22, 2023
1 parent dbce55c commit 7424e16
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/e2e/app-dir/next-image/next-image-https.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createNextDescribe } from '../../../lib/e2e-utils'

createNextDescribe(
'app dir next-image (with https)',
{
files: __dirname,
skipDeployment: true,
startCommand: `yarn next dev --experimental-https`,
},
({ next }) => {
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')

expect(src).toContain(
'/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.3f1a293b.png&w=828&q=90'
)

expect(failCount).toBe(0)
})
}
)

0 comments on commit 7424e16

Please sign in to comment.