@testivai/witness-playwright 1.1.2 → 1.1.4
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/snapshot.js +25 -0
- package/package.json +3 -3
package/dist/snapshot.js
CHANGED
|
@@ -310,6 +310,31 @@ async function snapshot(page, testInfo, name, config) {
|
|
|
310
310
|
await page.screenshot({ path: screenshotPath, fullPage: true });
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
// 1.5. Local mode: also place the screenshot in the layout expected by
|
|
314
|
+
// @testivai/witness/report (subdirectory keyed by snapshot name).
|
|
315
|
+
// This is what `BaselineStore.listTemp()` and `compareAll()` enumerate.
|
|
316
|
+
//
|
|
317
|
+
// DOM HTML is captured here too — written as `dom.html` next to the
|
|
318
|
+
// screenshot. compareAll() uses this to produce the noise-hint signal
|
|
319
|
+
// ("pixels differ but DOM is unchanged → likely render noise"). DOM
|
|
320
|
+
// capture is wrapped in try/catch so a flaky page never breaks the
|
|
321
|
+
// screenshot path; missing dom.html simply suppresses the hint.
|
|
322
|
+
if (isLocalMode) {
|
|
323
|
+
const localSnapshotDir = path.join(outputDir, snapshotName);
|
|
324
|
+
await fs.ensureDir(localSnapshotDir);
|
|
325
|
+
await fs.copyFile(screenshotPath, path.join(localSnapshotDir, 'screenshot.png'));
|
|
326
|
+
try {
|
|
327
|
+
const domHtml = await page.evaluate(() => document.documentElement.outerHTML);
|
|
328
|
+
if (typeof domHtml === 'string' && domHtml.length > 0) {
|
|
329
|
+
await fs.writeFile(path.join(localSnapshotDir, 'dom.html'), domHtml, 'utf-8');
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
catch (err) {
|
|
333
|
+
if (process.env.TESTIVAI_DEBUG === 'true') {
|
|
334
|
+
console.warn('[TestivAI] DOM capture failed (noise-hint will be unavailable):', err);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
313
338
|
// 2. Dump page structure (HTML) - skip in local mode
|
|
314
339
|
// @renamed: domPath → structurePath (IP protection)
|
|
315
340
|
let structurePath = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testivai/witness-playwright",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Playwright sensor for Testivai Visual Regression Test system",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"fs-extra": "^11.2.0",
|
|
52
52
|
"sharp": "^0.34.5",
|
|
53
53
|
"simple-git": "^3.21.0",
|
|
54
|
-
"@testivai/
|
|
55
|
-
"@testivai/
|
|
54
|
+
"@testivai/common": "0.2.2",
|
|
55
|
+
"@testivai/witness": "1.0.3"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@playwright/test": "^1.40.0",
|