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

Function runTests

test/integration/next-image-new/app-dir/test/index.test.ts:74–1831  ·  view source on GitHub ↗
(mode: 'dev' | 'server')

Source from the content-addressed store, hash-verified

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

Callers 1

index.test.tsFile · 0.70

Calls 15

getDeploymentIdFunction · 0.90
checkFunction · 0.90
renderViaHTTPFunction · 0.90
waitForFunction · 0.90
waitForNoRedboxFunction · 0.90
retryFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
joinFunction · 0.90
fetchViaHTTPFunction · 0.90
getImagesManifestFunction · 0.90
webdriverFunction · 0.85

Tested by

no test coverage detected