MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/next-image-new/base-path/test/index.test.ts:54–190  ·  view source on GitHub ↗
(mode: 'dev' | 'server')

Source from the content-addressed store, hash-verified

52}
53
54function runTests(mode: 'dev' | 'server') {
55 it('should load the images', async () => {
56 let browser
57 try {
58 browser = await webdriver(appPort, '/docs')
59
60 await check(async () => {
61 const result = await browser.eval(
62 `document.getElementById('basic-image').naturalWidth`
63 )
64
65 if (result === 0) {
66 throw new Error('Incorrectly loaded image')
67 }
68
69 return 'result-correct'
70 }, /result-correct/)
71
72 expect(await getImageUrls(browser)).toContain(
73 `http://localhost:${appPort}/docs/_next/image?url=%2Fdocs%2Ftest.jpg&w=828&q=75${getDeploymentId(appDir, mode === 'dev').getDeploymentIdQuery(true)}`
74 )
75 } finally {
76 if (browser) {
77 await browser.close()
78 }
79 }
80 })
81
82 it('should update the image on src change', async () => {
83 let browser
84 try {
85 browser = await webdriver(appPort, '/docs/update')
86
87 await check(
88 () => browser.eval(`document.getElementById("update-image").src`),
89 /test\.jpg/
90 )
91
92 await browser.eval(`document.getElementById("toggle").click()`)
93
94 await check(
95 () => browser.eval(`document.getElementById("update-image").src`),
96 /test\.png/
97 )
98 } finally {
99 if (browser) {
100 await browser.close()
101 }
102 }
103 })
104
105 it('should work when using flexbox', async () => {
106 let browser
107 try {
108 browser = await webdriver(appPort, '/docs/flex')
109 await check(async () => {
110 const result = await browser.eval(
111 `document.getElementById('basic-image').width`

Callers 1

index.test.tsFile · 0.70

Calls 15

checkFunction · 0.90
getDeploymentIdFunction · 0.90
waitForNoRedboxFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
waitForFunction · 0.90
webdriverFunction · 0.85
evalMethod · 0.80
getDeploymentIdQueryMethod · 0.80
getImageUrlsFunction · 0.70
getComputedFunction · 0.70
getRatioFunction · 0.70

Tested by

no test coverage detected