@@ -58,6 +58,36 @@ function waitUntilNoBusy() {
5858 ) ;
5959}
6060
61+ /**
62+ * Wait until all images are loaded.
63+ */
64+ function waitForImagesLoading ( ) {
65+ cy . waitUntil ( ( ) =>
66+ cy . document ( ) . then ( ( document ) => {
67+ const allImages = Array . from ( document . images ) ;
68+ allImages . forEach ( ( img ) => {
69+ img . loading = "eager" ;
70+ img . decoding = "sync" ;
71+ } ) ;
72+ return allImages . every ( ( img ) => img . complete && img . naturalWidth > 0 ) ;
73+ } )
74+ ) ;
75+ }
76+
77+ /**
78+ * Disable spellcheck on inputs, textareas, and contenteditable elements to avoid red underlines
79+ */
80+ function disableSpellCheck ( ) {
81+ cy . document ( ) . then ( ( document ) => {
82+ const query =
83+ "[contenteditable]:not([contenteditable=false]):not([spellcheck=false]), input:not([spellcheck=false]), textarea:not([spellcheck=false])" ;
84+ document . querySelectorAll ( query ) . forEach ( ( element ) => {
85+ element . setAttribute ( "spellcheck" , "false" ) ;
86+ } ) ;
87+ } ) ;
88+ return true ;
89+ }
90+
6191Cypress . Commands . add (
6292 "argosScreenshot" ,
6393 { prevSubject : [ "optional" , "element" , "window" , "document" ] } ,
@@ -83,16 +113,10 @@ Cypress.Commands.add(
83113 cy . document ( ) . its ( "fonts.status" ) . should ( "equal" , "loaded" ) ;
84114
85115 // Wait for images to be loaded
86- cy . waitUntil ( ( ) =>
87- cy . document ( ) . then ( ( document ) => {
88- const allImages = Array . from ( document . images ) ;
89- allImages . forEach ( ( img ) => {
90- img . loading = "eager" ;
91- img . decoding = "sync" ;
92- } ) ;
93- return allImages . every ( ( img ) => img . complete && img . naturalWidth > 0 ) ;
94- } )
95- ) ;
116+ waitForImagesLoading ( ) ;
117+
118+ // Wait for images to be loaded
119+ disableSpellCheck ( ) ;
96120
97121 // Screenshot
98122 cy . wrap ( subject ) . screenshot ( name , {
0 commit comments