@@ -12,67 +12,75 @@ test('SVG as inline component', async ({ page }) => {
12
12
await page . goto ( '/' )
13
13
const svg = page . locator ( '#inline-comp > svg' )
14
14
expect ( await outerHtml ( svg ) ) . toMatchSnapshot ( 'inline-comp.svg' )
15
+ await expect ( svg ) . toHaveScreenshot ( )
15
16
} )
16
17
17
18
test ( 'SVG as inline string' , async ( { page } ) => {
18
19
await page . goto ( '/' )
19
20
const svg = page . locator ( '#inline-string > svg' )
20
21
expect ( await outerHtml ( svg ) ) . toMatchSnapshot ( 'inline-string.svg' )
22
+ await expect ( svg ) . toHaveScreenshot ( )
21
23
} )
22
24
23
- // FIXME: This test breaks when running in this test context (we get a data url)
24
- // but it works fine when you look at the page in a browse when running
25
- // the server
26
- test . skip ( 'As URL in an image tag' , async ( { page } ) => {
25
+ test ( 'As URL in an image tag' , async ( { page } ) => {
27
26
await page . goto ( '/' )
28
27
const img = page . locator ( '#image > img' )
29
- expect ( ( await img . getAttribute ( 'src' ) ) . includes ( 'sample-logo' ) ) . toEqual ( true )
30
- expect ( await img . getAttribute ( 'alt' ) ) . toEqual ( 'Sample logo' )
28
+ await expect ( img ) . toHaveAttribute (
29
+ 'src' ,
30
+ expect . stringContaining ( 'sample-logo' )
31
+ )
32
+ await expect ( img ) . toHaveAttribute ( 'alt' , 'Sample logo' )
33
+ await expect ( img ) . toHaveScreenshot ( )
31
34
} )
32
35
33
36
test ( 'With component props' , async ( { page } ) => {
34
37
await page . goto ( '/' )
35
38
const svg = page . locator ( '#with-props > svg' )
36
- expect ( await svg . getAttribute ( 'width' ) ) . toEqual ( '200' )
37
- expect ( await svg . getAttribute ( 'aria-hidden' ) ) . toEqual ( 'false' )
39
+ await expect ( svg ) . toHaveAttribute ( 'width' , '200' )
40
+ await expect ( svg ) . toHaveAttribute ( 'aria-hidden' , 'false' )
41
+ await expect ( svg ) . toHaveScreenshot ( )
38
42
} )
39
43
40
44
test ( 'From another directory' , async ( { page } ) => {
41
45
await page . goto ( '/' )
42
46
const svg = page . locator ( '#from-another-dir > svg' )
43
47
expect ( await outerHtml ( svg ) ) . toMatchSnapshot ( 'from-another-dir.svg' )
48
+ await expect ( svg ) . toHaveScreenshot ( )
44
49
} )
45
50
46
51
test ( 'As data URL' , async ( { page } ) => {
47
52
await page . goto ( '/' )
48
53
const img = page . locator ( '#dataurl > img' )
49
54
expect ( await img . getAttribute ( 'src' ) ) . toMatchSnapshot ( 'base64imageurl.txt' )
55
+ await expect ( img ) . toHaveScreenshot ( )
50
56
} )
51
57
52
58
test ( 'As data URL with explicit base64' , async ( { page } ) => {
53
59
await page . goto ( '/dataurl' )
54
60
const img = page . locator ( '#b64e > img' )
55
61
expect ( await img . getAttribute ( 'src' ) ) . toMatchSnapshot ( 'base64explicit.txt' )
62
+ await expect ( img ) . toHaveScreenshot ( )
56
63
} )
57
64
58
65
test ( 'As data URL with explicit enc' , async ( { page } ) => {
59
66
await page . goto ( '/dataurl' )
60
67
const img = page . locator ( '#enc > img' )
61
68
expect ( await img . getAttribute ( 'src' ) ) . toMatchSnapshot ( 'enc.txt' )
69
+ await expect ( img ) . toHaveScreenshot ( )
62
70
} )
63
71
64
72
test ( 'As data URL with explicit unenc' , async ( { page } ) => {
65
73
await page . goto ( '/dataurl' )
66
74
const img = page . locator ( '#unenc > img' )
67
75
expect ( await img . getAttribute ( 'src' ) ) . toMatchSnapshot ( 'unenc.txt' )
76
+ await expect ( img ) . toHaveScreenshot ( )
68
77
} )
69
78
70
79
test ( 'Transform hook' , async ( { page } ) => {
71
80
await page . goto ( '/hook' )
72
81
const svg = page . locator ( 'svg > title' )
73
- const title = await svg . textContent ( )
74
82
75
- expect ( title ) . toEqual ( 'Official SVG Logo' )
83
+ await expect ( svg ) . toHaveText ( 'Official SVG Logo' )
76
84
} )
77
85
78
86
test ( 'Optimized URL import' , async ( { page } ) => {
0 commit comments