@uiverify/vitest 1.0.0 → 1.0.1
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/browser-setup.js +4 -0
- package/dist/chunk-X2KT34IP.js +40 -0
- package/dist/plugin.js +4 -28
- package/package.json +1 -1
package/dist/browser-setup.js
CHANGED
|
@@ -2,9 +2,13 @@ import {
|
|
|
2
2
|
autoSnapshot,
|
|
3
3
|
beginTest
|
|
4
4
|
} from "./chunk-ZCABESWT.js";
|
|
5
|
+
import {
|
|
6
|
+
UI_VERIFY_GLOBAL
|
|
7
|
+
} from "./chunk-X2KT34IP.js";
|
|
5
8
|
|
|
6
9
|
// src/browser-setup.ts
|
|
7
10
|
import { afterEach, beforeEach, inject } from "vitest";
|
|
11
|
+
Reflect.set(globalThis, UI_VERIFY_GLOBAL, true);
|
|
8
12
|
function globalAutoDisabled() {
|
|
9
13
|
try {
|
|
10
14
|
return Boolean(inject("__uiverify")?.disableAutoSnapshot);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// ../archive-core/src/out-dir.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
function resolveOutDir() {
|
|
4
|
+
return process.env.UIVERIFY_ARCHIVE_DIR ?? path.resolve(process.cwd(), "uiverify-archive");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// ../archive-core/src/ui-verify.ts
|
|
8
|
+
var UI_VERIFY_GLOBAL = "__UI_VERIFY__";
|
|
9
|
+
var UI_VERIFY_MARKER_SCRIPT = `globalThis.${UI_VERIFY_GLOBAL} = true;`;
|
|
10
|
+
|
|
11
|
+
// ../archive-core/src/write.ts
|
|
12
|
+
import fs from "fs";
|
|
13
|
+
import path2 from "path";
|
|
14
|
+
|
|
15
|
+
// ../archive-core/src/snapshot-file.ts
|
|
16
|
+
import { createHash } from "crypto";
|
|
17
|
+
function snapshotFileName(id) {
|
|
18
|
+
const slug = id.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
19
|
+
const hash = createHash("sha1").update(id).digest("hex").slice(0, 10);
|
|
20
|
+
return `${slug || "snapshot"}-${hash}.json`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ../archive-core/src/write.ts
|
|
24
|
+
function writeSnapshot(outDir, snapshot) {
|
|
25
|
+
const dir = path2.join(outDir, "snapshots");
|
|
26
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
27
|
+
const file = path2.join(dir, snapshotFileName(snapshot.id));
|
|
28
|
+
fs.writeFileSync(file, JSON.stringify(snapshot));
|
|
29
|
+
return file;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ../archive-core/src/finalize.ts
|
|
33
|
+
import fs2 from "fs";
|
|
34
|
+
import path3 from "path";
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
resolveOutDir,
|
|
38
|
+
UI_VERIFY_GLOBAL,
|
|
39
|
+
writeSnapshot
|
|
40
|
+
};
|
package/dist/plugin.js
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const hash = createHash("sha1").update(id).digest("hex").slice(0, 10);
|
|
6
|
-
return `${slug || "snapshot"}-${hash}.json`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// ../archive-core/src/out-dir.ts
|
|
10
|
-
import path from "path";
|
|
11
|
-
function resolveOutDir() {
|
|
12
|
-
return process.env.UIVERIFY_ARCHIVE_DIR ?? path.resolve(process.cwd(), "uiverify-archive");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// ../archive-core/src/write.ts
|
|
16
|
-
import fs from "fs";
|
|
17
|
-
import path2 from "path";
|
|
18
|
-
function writeSnapshot(outDir, snapshot) {
|
|
19
|
-
const dir = path2.join(outDir, "snapshots");
|
|
20
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
21
|
-
const file = path2.join(dir, snapshotFileName(snapshot.id));
|
|
22
|
-
fs.writeFileSync(file, JSON.stringify(snapshot));
|
|
23
|
-
return file;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ../archive-core/src/finalize.ts
|
|
27
|
-
import fs2 from "fs";
|
|
28
|
-
import path3 from "path";
|
|
1
|
+
import {
|
|
2
|
+
resolveOutDir,
|
|
3
|
+
writeSnapshot
|
|
4
|
+
} from "./chunk-X2KT34IP.js";
|
|
29
5
|
|
|
30
6
|
// src/plugin.ts
|
|
31
7
|
var SETUP_MODULE = "@uiverify/vitest/browser-setup";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiverify/vitest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Vitest browser-mode capture SDK for UI Verify (uiverify.ai): add uiverifyPlugin() to your Vitest config and each browser-mode test archives its final DOM (serialized DOM + resource bytes) to be replayed + visually diffed by UI Verify. Produces an archive the uiverify CLI uploads; talks to nothing at runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visual-testing",
|