@testivai/witness-webdriverio 0.4.5 → 0.4.6
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/dist/types.d.ts +6 -0
- package/dist/witness.js +29 -1
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export interface WitnessBrowser {
|
|
|
18
18
|
* Type kept loose to accept WDIO 8/9 signature variants.
|
|
19
19
|
*/
|
|
20
20
|
execute<T = unknown>(script: string | ((...args: any[]) => T), ...args: any[]): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* The session's W3C capabilities (WebdriverIO's `browser.capabilities`).
|
|
23
|
+
* Optional: when present, the browser, its version and the driver are
|
|
24
|
+
* recorded as capture provenance in the capture's metadata.json.
|
|
25
|
+
*/
|
|
26
|
+
capabilities?: Record<string, unknown>;
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
29
|
* Options for a single witness() call. All optional.
|
package/dist/witness.js
CHANGED
|
@@ -57,6 +57,8 @@ exports.witness = witness;
|
|
|
57
57
|
const fs = __importStar(require("fs"));
|
|
58
58
|
const path = __importStar(require("path"));
|
|
59
59
|
const witness_1 = require("@testivai/witness");
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
61
|
+
const ADAPTER_VERSION = require('../package.json').version;
|
|
60
62
|
const element_map_1 = require("./element-map");
|
|
61
63
|
/** id of the style element injected for the duration of a capture */
|
|
62
64
|
const STYLE_ID = '__testivai_capture_css__';
|
|
@@ -138,10 +140,28 @@ async function witness(browser, name, options = {}) {
|
|
|
138
140
|
if (options.variant) {
|
|
139
141
|
name = `${name}__${options.variant.replace(/[^a-z0-9_-]+/gi, '_').toLowerCase()}`;
|
|
140
142
|
}
|
|
143
|
+
const localConfig = (0, witness_1.loadLocalConfig)(process.cwd());
|
|
144
|
+
// Capture provenance: what the page is rendered with, measured before
|
|
145
|
+
// anything is injected, plus the session's capabilities. Best-effort.
|
|
146
|
+
let renderProbe = null;
|
|
147
|
+
if (typeof browser.execute === 'function') {
|
|
148
|
+
try {
|
|
149
|
+
renderProbe = await browser.execute(`return ${witness_1.RENDER_PROBE_EXPRESSION}`);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// no probe: no render settings recorded
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const environment = (0, witness_1.webDriverEnvironment)({
|
|
156
|
+
capabilities: browser.capabilities,
|
|
157
|
+
probe: renderProbe,
|
|
158
|
+
adapter: { name: '@testivai/witness-webdriverio', version: ADAPTER_VERSION, captureMethod: witness_1.CAPTURE_METHODS.WEBDRIVER_VIEWPORT },
|
|
159
|
+
framework: { name: 'webdriverio', version: (0, witness_1.installedPackageVersion)('webdriverio') },
|
|
160
|
+
});
|
|
161
|
+
name = (0, witness_1.applyEnvironmentPolicyToName)(name, { browser: { name: environment?.browser.name ?? 'unknown' }, os: { platform: process.platform } }, localConfig.environmentPolicy);
|
|
141
162
|
// 0. Prepare the page: stabilization CSS (animations/caret/fonts — the
|
|
142
163
|
// flake killers) + ignoreSelectors from config.json and this call,
|
|
143
164
|
// injected as one style tag and removed after the capture.
|
|
144
|
-
const localConfig = (0, witness_1.loadLocalConfig)(process.cwd());
|
|
145
165
|
const stabilize = options.stabilize ?? localConfig.stabilize;
|
|
146
166
|
const ignoreSelectors = [
|
|
147
167
|
...new Set([...(localConfig.ignoreSelectors ?? []), ...(options.ignoreSelectors ?? [])]),
|
|
@@ -215,6 +235,14 @@ async function witness(browser, name, options = {}) {
|
|
|
215
235
|
// 4. Write to .testivai/temp/<name>/
|
|
216
236
|
const store = new witness_1.BaselineStore(process.cwd());
|
|
217
237
|
store.writeTemp(name, screenshot, dom);
|
|
238
|
+
if (environment) {
|
|
239
|
+
try {
|
|
240
|
+
store.writeTempMetadata(name, { name, environment });
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
// without it the compare cannot tell rendering drift from noise for this capture
|
|
244
|
+
}
|
|
245
|
+
}
|
|
218
246
|
if (elementMap) {
|
|
219
247
|
try {
|
|
220
248
|
const tempDir = path.join(process.cwd(), '.testivai', 'temp', name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testivai/witness-webdriverio",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "WebdriverIO adapter for TestivAI Witness — local-first visual regression with pixel + DOM comparison",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@testivai/witness": "2.
|
|
57
|
+
"@testivai/witness": "2.5.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/jest": "^30.0.0",
|