snapdrift 0.8.2 → 0.10.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/CHANGELOG.md +74 -0
- package/README.md +8 -3
- package/action.yml +10 -2
- package/actions/comment/action.yml +6 -0
- package/actions/compare/action.yml +6 -0
- package/actions/pr-diff/action.yml +102 -55
- package/actions/resolve-baseline/action.yml +36 -50
- package/actions/scope/action.yml +24 -1
- package/actions/stage/action.yml +7 -1
- package/bin/snapdrift.mjs +6 -3
- package/docs/contracts.md +125 -9
- package/docs/integration-guide.md +61 -12
- package/docs/local-cli.md +15 -1
- package/docs/workflow-templates/refresh-baseline-on-merge.yml +1 -1
- package/lib/cli.mjs +140 -52
- package/lib/init-from-action.mjs +24 -13
- package/lib/outage-policy.mjs +35 -2
- package/lib/provider.mjs +39 -12
- package/lib/report.mjs +3 -2
- package/lib/resolve-baseline-artifact.mjs +147 -0
- package/lib/resolve-baseline-paths.mjs +40 -0
- package/lib/snap-provider.mjs +1164 -481
- package/package.json +15 -11
- package/types/visual-diff-types.d.ts +30 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snapdrift",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "SnapDrift captures, compares, and reports UI drift for Playwright-based app checks.",
|
|
@@ -25,12 +25,15 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"lint": "eslint .",
|
|
27
27
|
"typecheck": "tsc --project tsconfig.json",
|
|
28
|
+
"check:package-types": "node scripts/check-package-types.mjs",
|
|
29
|
+
"check:package-runtime": "node scripts/check-package-runtime.mjs",
|
|
28
30
|
"validate:actions": "node scripts/validate-actions.mjs",
|
|
29
31
|
"validate:release": "node scripts/validate-release.mjs",
|
|
32
|
+
"check:pin-stale": "node scripts/check-pin-stale.mjs",
|
|
30
33
|
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
31
34
|
"test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage --runInBand",
|
|
32
35
|
"pack:check": "npm pack --dry-run --cache .npm-cache",
|
|
33
|
-
"ci": "npm run lint && npm run typecheck && npm run validate:actions && npm run test:coverage && npm run pack:check"
|
|
36
|
+
"ci": "npm run lint && npm run typecheck && npm run check:package-types && npm run check:package-runtime && npm run validate:actions && npm run test:coverage && npm run pack:check"
|
|
34
37
|
},
|
|
35
38
|
"engines": {
|
|
36
39
|
"node": ">=22"
|
|
@@ -41,7 +44,6 @@
|
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"@eslint/js": "^10.0.1",
|
|
43
46
|
"@types/jest": "^30.0.0",
|
|
44
|
-
"@types/js-yaml": "^4.0.9",
|
|
45
47
|
"@types/node": "^26.1.0",
|
|
46
48
|
"@types/pngjs": "^6.0.5",
|
|
47
49
|
"eslint": "^10.2.0",
|
|
@@ -80,9 +82,11 @@
|
|
|
80
82
|
"./lib/provider.mjs": "./lib/provider.mjs",
|
|
81
83
|
"./lib/outage-policy.mjs": "./lib/outage-policy.mjs",
|
|
82
84
|
"./lib/snap-provider.mjs": "./lib/snap-provider.mjs",
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
"./lib/migrate-baselines.mjs": "./lib/migrate-baselines.mjs",
|
|
86
|
+
"./lib/init-from-action.mjs": "./lib/init-from-action.mjs",
|
|
87
|
+
"./lib/resolve-baseline-paths.mjs": "./lib/resolve-baseline-paths.mjs",
|
|
88
|
+
"./lib/resolve-baseline-artifact.mjs": "./lib/resolve-baseline-artifact.mjs"
|
|
89
|
+
},
|
|
86
90
|
"files": [
|
|
87
91
|
"action.yml",
|
|
88
92
|
"actions/",
|
|
@@ -98,11 +102,11 @@
|
|
|
98
102
|
"registry": "https://registry.npmjs.org"
|
|
99
103
|
},
|
|
100
104
|
"dependencies": {
|
|
101
|
-
"@snapdrift/adapter-fs": "^1.0
|
|
102
|
-
"@snapdrift/adapter-report-md": "^1.
|
|
103
|
-
"@snapdrift/compare-core": "^1.
|
|
104
|
-
"@snapdrift/manifest": "^1.
|
|
105
|
-
"js-yaml": "^5.
|
|
105
|
+
"@snapdrift/adapter-fs": "^1.2.0",
|
|
106
|
+
"@snapdrift/adapter-report-md": "^1.2.0",
|
|
107
|
+
"@snapdrift/compare-core": "^1.1.0",
|
|
108
|
+
"@snapdrift/manifest": "^1.4.0",
|
|
109
|
+
"js-yaml": "^5.4.0",
|
|
106
110
|
"playwright": "^1.59.1",
|
|
107
111
|
"pngjs": "^7.0.0"
|
|
108
112
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { SnapConfig } from '@snapdrift/manifest';
|
|
2
|
+
|
|
1
3
|
/** Object-shaped data decoded from an external JSON or YAML boundary. */
|
|
2
4
|
export type JsonObject = Record<string, any>;
|
|
3
5
|
|
|
4
6
|
export type VisualViewportPreset = 'desktop' | 'mobile';
|
|
5
|
-
export interface VisualCustomViewport {
|
|
7
|
+
export interface VisualCustomViewport {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
6
11
|
export type VisualViewport = VisualViewportPreset | VisualCustomViewport;
|
|
7
12
|
|
|
8
13
|
export interface VisualRegressionSelectionConfig {
|
|
@@ -10,6 +15,24 @@ export interface VisualRegressionSelectionConfig {
|
|
|
10
15
|
sharedExact?: string[];
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
export interface ComparisonPolicy {
|
|
19
|
+
version: 1;
|
|
20
|
+
threshold: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ComparisonDimensions {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ComparisonMetadata {
|
|
29
|
+
baseline: ComparisonDimensions;
|
|
30
|
+
current: ComparisonDimensions;
|
|
31
|
+
canvas: ComparisonDimensions;
|
|
32
|
+
dimensionsChanged: boolean;
|
|
33
|
+
totalPixels: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
13
36
|
export interface VisualRegressionRouteConfig {
|
|
14
37
|
id: string;
|
|
15
38
|
path: string;
|
|
@@ -29,6 +52,7 @@ export interface VisualRegressionConfig {
|
|
|
29
52
|
diff: {
|
|
30
53
|
threshold: number;
|
|
31
54
|
mode: 'report-only' | 'fail-on-changes' | 'fail-on-incomplete' | 'strict';
|
|
55
|
+
comparisonPolicy?: ComparisonPolicy;
|
|
32
56
|
};
|
|
33
57
|
selection?: VisualRegressionSelectionConfig;
|
|
34
58
|
provider?: 'local' | 'snap';
|
|
@@ -86,6 +110,8 @@ export interface SnapRunMetadata {
|
|
|
86
110
|
runId: string;
|
|
87
111
|
projectId: string;
|
|
88
112
|
purpose: 'baseline' | 'capture' | 'diff';
|
|
113
|
+
/** Exact comparison policy acknowledged by Snap for updated clients. */
|
|
114
|
+
comparisonPolicy?: ComparisonPolicy;
|
|
89
115
|
/** CI source branch for hosted baseline runs; omitted for ordinary diff runs. */
|
|
90
116
|
refBranch?: string;
|
|
91
117
|
/** Resolved 40-character CI commit for hosted baseline runs. */
|
|
@@ -139,6 +165,8 @@ export interface VisualDiffChangedItem {
|
|
|
139
165
|
totalPixels: number;
|
|
140
166
|
mismatchRatio: number;
|
|
141
167
|
status: 'changed';
|
|
168
|
+
comparison?: ComparisonMetadata;
|
|
169
|
+
diffImagePath?: string;
|
|
142
170
|
}
|
|
143
171
|
|
|
144
172
|
export interface VisualDiffSummary {
|
|
@@ -165,6 +193,7 @@ export interface VisualDiffSummary {
|
|
|
165
193
|
missing: VisualDiffMissingItem[];
|
|
166
194
|
errors: VisualDiffErrorItem[];
|
|
167
195
|
dimensionChanges: VisualDiffDimensionItem[];
|
|
196
|
+
comparisonPolicy?: ComparisonPolicy;
|
|
168
197
|
message?: string;
|
|
169
198
|
/** Link to the provider's run detail page. Set by SnapProvider during diff(); undefined for LocalProvider. */
|
|
170
199
|
dashboardUrl?: string;
|