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

Function runTests

test/integration/next-image-legacy/basic/test/index.test.ts:21–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
20
21function runTests() {
22 it('should render an image tag', async () => {
23 await waitFor(1000)
24 expect(await browser.hasElementByCssSelector('img')).toBeTruthy()
25 })
26 it('should support passing through arbitrary attributes', async () => {
27 expect(
28 await browser.hasElementByCssSelector('img#attribute-test')
29 ).toBeTruthy()
30 expect(
31 await browser.elementByCss('img#attribute-test').getAttribute('data-demo')
32 ).toBe('demo-value')
33 })
34 it('should modify src with the loader', async () => {
35 expect(await browser.elementById('basic-image').getAttribute('src')).toBe(
36 'https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=1024&q=60'
37 )
38 })
39 it('should correctly generate src even if preceding slash is included in prop', async () => {
40 expect(
41 await browser.elementById('preceding-slash-image').getAttribute('src')
42 ).toBe(
43 'https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=1024'
44 )
45 })
46 it('should add a srcset based on the loader', async () => {
47 expect(
48 await browser.elementById('basic-image').getAttribute('srcset')
49 ).toBe(
50 'https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=480&q=60 1x, https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=1024&q=60 2x'
51 )
52 })
53 it('should add a srcset even with preceding slash in prop', async () => {
54 expect(
55 await browser.elementById('preceding-slash-image').getAttribute('srcset')
56 ).toBe(
57 'https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=480 1x, https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=1024 2x'
58 )
59 })
60 it('should use imageSizes when width matches, not deviceSizes from next.config.js', async () => {
61 expect(await browser.elementById('icon-image-16').getAttribute('src')).toBe(
62 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=32'
63 )
64 expect(
65 await browser.elementById('icon-image-16').getAttribute('srcset')
66 ).toBe(
67 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=16 1x, https://example.com/myaccount/icon.png?auto=format&fit=max&w=32 2x'
68 )
69 expect(await browser.elementById('icon-image-32').getAttribute('src')).toBe(
70 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=64'
71 )
72 expect(
73 await browser.elementById('icon-image-32').getAttribute('srcset')
74 ).toBe(
75 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=32 1x, https://example.com/myaccount/icon.png?auto=format&fit=max&w=64 2x'
76 )
77 })
78 it('should support the unoptimized attribute', async () => {

Callers 1

index.test.tsFile · 0.70

Calls 7

waitForFunction · 0.90
getAttributeMethod · 0.80
elementByCssMethod · 0.80
elementByIdMethod · 0.80
itFunction · 0.50
expectFunction · 0.50

Tested by

no test coverage detected