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

Function runTests

test/integration/next-image-legacy/default/test/index.test.ts:72–1482  ·  view source on GitHub ↗
(mode: 'dev' | 'server')

Source from the content-addressed store, hash-verified

70}
71
72function runTests(mode: 'dev' | 'server') {
73 let dpl: string
74 beforeAll(() => {
75 dpl = getDeploymentId(appDir, mode === 'dev').getDeploymentIdQuery(true)
76 })
77
78 it('should load the images', async () => {
79 let browser
80 try {
81 browser = await webdriver(appPort, '/')
82
83 await check(async () => {
84 const result = await browser.eval(
85 `document.getElementById('basic-image').naturalWidth`
86 )
87
88 if (result === 0) {
89 throw new Error('Incorrectly loaded image')
90 }
91
92 return 'result-correct'
93 }, /result-correct/)
94
95 expect(await getImageUrls(browser)).toContain(
96 `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=828&q=75${dpl}`
97 )
98 } finally {
99 if (browser) {
100 await browser.close()
101 }
102 }
103 })
104
105 it('should preload priority images', async () => {
106 let browser
107 try {
108 browser = await webdriver(appPort, '/priority')
109
110 await check(async () => {
111 const result = await browser.eval(
112 `document.getElementById('basic-image').naturalWidth`
113 )
114
115 if (result === 0) {
116 throw new Error('Incorrectly loaded image')
117 }
118
119 return 'result-correct'
120 }, /result-correct/)
121
122 const links = await browser.elementsByCss('link[rel=preload][as=image]')
123 const entries = []
124 for (const link of links) {
125 const imagesrcset = await link.getAttribute('imagesrcset')
126 const imagesizes = await link.getAttribute('imagesizes')
127 entries.push({ imagesrcset, imagesizes })
128 }
129

Callers 1

index.test.tsFile · 0.70

Calls 15

getDeploymentIdFunction · 0.90
checkFunction · 0.90
renderViaHTTPFunction · 0.90
waitForFunction · 0.90
waitForNoRedboxFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
joinFunction · 0.90
fetchViaHTTPFunction · 0.90
webdriverFunction · 0.85
getDeploymentIdQueryMethod · 0.80
evalMethod · 0.80

Tested by

no test coverage detected