@syngrisi/wdio-sdk 3.16.0 → 3.17.0

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.
package/README.md CHANGED
@@ -104,6 +104,10 @@ await driver.startTestSession({ params: sessionParams });
104
104
  Perform a visual check by providing the check name, image buffer, and any additional parameters.
105
105
 
106
106
  ```js
107
+ // Wait for webfonts before capturing — screenshots taken before a
108
+ // `font-display: swap` font finishes loading produce flaky "shifted text" diffs
109
+ await driver.waitForFonts();
110
+
107
111
  // Full page screenshot
108
112
  const fullPageScreenshot = await browser.saveScreenshot('./screenshot.png');
109
113
  await driver.check({
@@ -177,6 +177,21 @@ class WDIODriver {
177
177
  }
178
178
  return result;
179
179
  }
180
+ /**
181
+ * Waits until all webfonts declared on the page are loaded.
182
+ * Call it right before taking a screenshot to avoid flaky "slightly shifted text"
183
+ * diffs caused by `font-display: swap` fonts swapping in after the capture.
184
+ * Resolves silently after `timeout` ms even if fonts are still loading.
185
+ *
186
+ * @param {number} [timeout=5000] - Maximum time to wait for fonts, in milliseconds.
187
+ * @example
188
+ * await driver.waitForFonts();
189
+ * const screenshot = Buffer.from(await browser.takeScreenshot(), 'base64');
190
+ * await driver.check({ checkName: 'Homepage', imageBuffer: screenshot, params: {} });
191
+ */
192
+ async waitForFonts(timeout = 5000) {
193
+ await (0, wdioHelpers_1.waitForFonts)(timeout);
194
+ }
180
195
  /**
181
196
  * Submits a check to Syngrisi with the provided image and associated test details.
182
197
  * @param {string} checkName - Name of the check.
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBrowserVersion = exports.getBrowserFullVersion = exports.isIos = exports.isAndroid = exports.getBrowserName = exports.getOS = exports.getViewport = void 0;
6
+ exports.waitForFonts = exports.getBrowserVersion = exports.getBrowserFullVersion = exports.isIos = exports.isAndroid = exports.getBrowserName = exports.getOS = exports.getViewport = void 0;
7
7
  const logger_1 = __importDefault(require("./logger"));
8
8
  const log = (0, logger_1.default)('syngrisi-wdio-sdk');
9
9
  if (process.env.SYNGRISI_LOG_LEVEL) {
@@ -117,3 +117,21 @@ const getBrowserVersion = () => {
117
117
  return fullVersion.split('.')[0];
118
118
  };
119
119
  exports.getBrowserVersion = getBrowserVersion;
120
+ /**
121
+ * Waits until all webfonts declared on the page are loaded.
122
+ * Call it right before taking a screenshot to avoid flaky "slightly shifted text"
123
+ * diffs caused by `font-display: swap` fonts swapping in after the capture.
124
+ * Resolves silently after `timeout` ms even if fonts are still loading.
125
+ */
126
+ const waitForFonts = async (timeout = 5000) => {
127
+ const start = Date.now();
128
+ // ponytail: polling instead of executeAsync (deprecated in modern WDIO)
129
+ while (Date.now() - start < timeout) {
130
+ const loaded = await browser.execute(() => globalThis.document?.fonts?.status === 'loaded');
131
+ if (loaded)
132
+ return;
133
+ await browser.pause(100);
134
+ }
135
+ log.warn(`waitForFonts: webfonts are still loading after ${timeout}ms`);
136
+ };
137
+ exports.waitForFonts = waitForFonts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syngrisi/wdio-sdk",
3
- "version": "3.16.0",
3
+ "version": "3.17.0",
4
4
  "description": "Syngrisi WebdriverIO SDK — visual regression testing for the Syngrisi Visual Testing Platform",
5
5
  "main": "dist/WDIODriver.js",
6
6
  "types": "dist/WDIODriver.d.ts",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://github.com/syngrisi/syngrisi/tree/main/packages/wdio-sdk#readme",
40
40
  "dependencies": {
41
- "@syngrisi/core-api": "^3.16.0",
41
+ "@syngrisi/core-api": "^3.17.0",
42
42
  "form-data": "^4.0.6",
43
43
  "loglevel": "^1.9.2",
44
44
  "zod": "^4.1.13"
@@ -63,5 +63,5 @@
63
63
  "typescript": "^6.0.3",
64
64
  "vitest": "^4.1.9"
65
65
  },
66
- "gitHead": "fe1663bce3a1db72833fe1434c9030b5f75c0b7d"
66
+ "gitHead": "d674bf0296c42762f95d883d313fd1612c24e3ff"
67
67
  }