@argos-ci/cypress 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/support.js +34 -10
package/README.md CHANGED
@@ -17,4 +17,4 @@ Visit [argos-ci.com/docs/cypress](https://argos-ci.com/docs/cypress) for guides,
17
17
  ## Links
18
18
 
19
19
  - [Official SDK Docs](https://argos-ci.com/docs)
20
- - [Discord](https://discord.gg/WjzGrQGS4A)
20
+ - [Discord](https://argos-ci.com/discord)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/cypress",
3
3
  "description": "Visual testing solution to avoid visual regression. Cypress commands and utilities for Argos visual testing.",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": "github:argos-ci/argos-cypress",
package/support.js CHANGED
@@ -58,6 +58,36 @@ function waitUntilNoBusy() {
58
58
  );
59
59
  }
60
60
 
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
+
61
91
  Cypress.Commands.add(
62
92
  "argosScreenshot",
63
93
  { prevSubject: ["optional", "element", "window", "document"] },
@@ -83,16 +113,10 @@ Cypress.Commands.add(
83
113
  cy.document().its("fonts.status").should("equal", "loaded");
84
114
 
85
115
  // 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();
96
120
 
97
121
  // Screenshot
98
122
  cy.wrap(subject).screenshot(name, {