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

Function runTests

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

Source from the content-addressed store, hash-verified

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

Callers 1

index.test.tsFile · 0.70

Calls 15

getDeploymentIdFunction · 0.90
checkFunction · 0.90
waitForNoRedboxFunction · 0.90
waitForRedboxFunction · 0.90
getRedboxHeaderFunction · 0.90
waitForFunction · 0.90
webdriverFunction · 0.85
getDeploymentIdQueryMethod · 0.80
evalMethod · 0.80
getAttributeMethod · 0.80
elementByIdMethod · 0.80
setDimensionsMethod · 0.80

Tested by

no test coverage detected