@cronn/element-snapshot 0.29.0 → 0.30.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/dist/index.mjs +13 -8
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expect } from "@playwright/test";
|
|
2
2
|
import { defineJsonFileMatcher, defineTextFileMatcher } from "@cronn/playwright-file-snapshots";
|
|
3
3
|
import { MarkdownTableSerializer } from "@cronn/lib-file-snapshots";
|
|
4
|
+
import fs from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { packageDirectory } from "package-directory";
|
|
6
7
|
//#region src/utils/guards.ts
|
|
@@ -65,7 +66,8 @@ function hasChildren(snapshot) {
|
|
|
65
66
|
}
|
|
66
67
|
//#endregion
|
|
67
68
|
//#region src/playwright/proxy.ts
|
|
68
|
-
var ElementSnapshotProxy = class {
|
|
69
|
+
var ElementSnapshotProxy = class ElementSnapshotProxy {
|
|
70
|
+
static browserLibSource = void 0;
|
|
69
71
|
page;
|
|
70
72
|
constructor(page) {
|
|
71
73
|
this.page = page;
|
|
@@ -80,14 +82,17 @@ var ElementSnapshotProxy = class {
|
|
|
80
82
|
return await this.page.evaluate(() => typeof window.snapshotElement === "function");
|
|
81
83
|
}
|
|
82
84
|
async loadLibrary() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await this.page.addScriptTag({ path: libPath });
|
|
85
|
+
ElementSnapshotProxy.browserLibSource ??= await this.readBrowserLibSource();
|
|
86
|
+
await this.page.evaluate(ElementSnapshotProxy.browserLibSource);
|
|
86
87
|
}
|
|
87
|
-
async
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
async readBrowserLibSource() {
|
|
89
|
+
const libPath = await this.resolveFromPackageRoot("dist", "browser-lib.iife.js");
|
|
90
|
+
return await fs.readFile(libPath, "utf8");
|
|
91
|
+
}
|
|
92
|
+
async resolveFromPackageRoot(...paths) {
|
|
93
|
+
const packageRoot = await packageDirectory({ cwd: import.meta.dirname });
|
|
94
|
+
if (packageRoot === void 0) throw new Error("Unable to resolve root directory of package");
|
|
95
|
+
return path.resolve(packageRoot, ...paths);
|
|
91
96
|
}
|
|
92
97
|
};
|
|
93
98
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cronn/element-snapshot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Element snapshots for Playwright",
|
|
5
5
|
"homepage": "https://cronn.github.io/file-snapshots/playwright/element-snapshots/",
|
|
6
6
|
"bugs": {
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cronn/lib-file-snapshots": "1.2.
|
|
29
|
-
"@cronn/playwright-file-snapshots": "2.2.
|
|
30
|
-
"package-directory": "8.2.0"
|
|
28
|
+
"@cronn/lib-file-snapshots": "1.2.2",
|
|
29
|
+
"@cronn/playwright-file-snapshots": "2.2.2",
|
|
30
|
+
"package-directory": "^8.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@arethetypeswrong/core": "0.18.5",
|
|
34
34
|
"@cronn/shared-configs": "0.0.0",
|
|
35
35
|
"@cronn/test-utils": "0.0.0",
|
|
36
|
-
"@cronn/vitest-file-snapshots": "2.1.
|
|
36
|
+
"@cronn/vitest-file-snapshots": "2.1.3",
|
|
37
37
|
"@playwright/test": "1.62.1",
|
|
38
38
|
"@types/node": "24.13.3",
|
|
39
39
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
40
40
|
"@vitest/coverage-v8": "4.1.11",
|
|
41
|
-
"eslint": "10.9.
|
|
41
|
+
"eslint": "10.9.1",
|
|
42
42
|
"eslint-config-prettier": "10.1.8",
|
|
43
43
|
"eslint-plugin-check-file": "3.3.2",
|
|
44
44
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"rimraf": "6.1.3",
|
|
47
47
|
"tsdown": "0.22.14",
|
|
48
48
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
49
|
-
"typescript-eslint": "8.
|
|
49
|
+
"typescript-eslint": "8.68.0",
|
|
50
50
|
"vitest": "4.1.11",
|
|
51
51
|
"node": "runtime:24.20.0"
|
|
52
52
|
},
|