Skip to content

Commit 7cfcc33

Browse files
authored
feat: Add custom CSS for screenshots
1 parent f6ed97c commit 7cfcc33

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

src/baseConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export const baseConfig: FrameworkTestConfig = {
2424
screenshot: 'only-on-failure'
2525
},
2626

27+
/* Add custom css for screenshots */
28+
expect: {
29+
toHaveScreenshot: {
30+
stylePath: __dirname + '/screenshot.css'
31+
},
32+
},
33+
2734
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2835
reporter: (
2936
process.env.CI ?

src/screenshot.css

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* All elements
3+
*/
4+
*,
5+
*::before,
6+
*::after {
7+
/* Remove all animations */
8+
animation-delay: -1ms !important;
9+
animation-duration: 1ms !important;
10+
animation-iteration-count: 1 !important;
11+
background-attachment: initial !important;
12+
scroll-behavior: auto !important;
13+
transition-duration: 0s !important;
14+
transition-delay: 0s !important;
15+
16+
/* Make everything visible */
17+
opacity: 1 !important;
18+
visibility: visible !important;
19+
}
20+
21+
/*
22+
* Specific Elements
23+
*/
24+
25+
/* Hide all iframe content */
26+
iframe {
27+
visibility: hidden !important;
28+
background-color: salmon;
29+
}
30+
31+
/*
32+
* Cookie Popups
33+
*/
34+
.cookiePolicy,
35+
#cookieman-modal,
36+
#CybotCookiebotDialog,
37+
#hs-eu-cookie-confirmation,
38+
#termly-code-snippet-support {
39+
display: none !important;
40+
}
41+
42+
/*
43+
* Modal Popups
44+
*/
45+
#hs-interactives-modal-overlay {
46+
display: none !important;
47+
}

0 commit comments

Comments
 (0)