@visual-check/cli 0.1.2 → 0.2.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/addon-child/image-files.js +1 -1
- package/dist/addon-child/image-files.js.map +1 -1
- package/dist/agent-skill/skill-files.d.ts +4 -0
- package/dist/agent-skill/skill-files.d.ts.map +1 -1
- package/dist/agent-skill/skill-files.js +4 -0
- package/dist/agent-skill/skill-files.js.map +1 -1
- package/dist/baselines/baseline-error.d.ts +15 -2
- package/dist/baselines/baseline-error.d.ts.map +1 -1
- package/dist/baselines/baseline-error.js +32 -2
- package/dist/baselines/baseline-error.js.map +1 -1
- package/dist/capture/capture-session.d.ts +161 -30
- package/dist/capture/capture-session.d.ts.map +1 -1
- package/dist/capture/capture-session.js +291 -72
- package/dist/capture/capture-session.js.map +1 -1
- package/dist/capture/driver/cdp/cdp-page.d.ts.map +1 -1
- package/dist/capture/driver/cdp/cdp-page.js +120 -31
- package/dist/capture/driver/cdp/cdp-page.js.map +1 -1
- package/dist/capture/driver/cdp/failed-loads.d.ts +16 -0
- package/dist/capture/driver/cdp/failed-loads.d.ts.map +1 -0
- package/dist/capture/driver/cdp/failed-loads.js +71 -0
- package/dist/capture/driver/cdp/failed-loads.js.map +1 -0
- package/dist/capture/driver/cdp/launch-arguments.d.ts +7 -1
- package/dist/capture/driver/cdp/launch-arguments.d.ts.map +1 -1
- package/dist/capture/driver/cdp/launch-arguments.js +8 -1
- package/dist/capture/driver/cdp/launch-arguments.js.map +1 -1
- package/dist/capture/driver/driver.d.ts +88 -4
- package/dist/capture/driver/driver.d.ts.map +1 -1
- package/dist/capture/driver/driver.js +33 -0
- package/dist/capture/driver/driver.js.map +1 -1
- package/dist/capture/frames.d.ts +10 -0
- package/dist/capture/frames.d.ts.map +1 -1
- package/dist/capture/frames.js +67 -0
- package/dist/capture/frames.js.map +1 -1
- package/dist/capture/page-script.d.ts +19 -8
- package/dist/capture/page-script.d.ts.map +1 -1
- package/dist/capture/page-script.js +46 -12
- package/dist/capture/page-script.js.map +1 -1
- package/dist/capture/prepare-capture.d.ts +50 -3
- package/dist/capture/prepare-capture.d.ts.map +1 -1
- package/dist/capture/prepare-capture.js +157 -16
- package/dist/capture/prepare-capture.js.map +1 -1
- package/dist/commands/check-storybooks.d.ts +5 -4
- package/dist/commands/check-storybooks.d.ts.map +1 -1
- package/dist/commands/check-storybooks.js +11 -8
- package/dist/commands/check-storybooks.js.map +1 -1
- package/dist/commands/consistency-output.d.ts.map +1 -1
- package/dist/commands/consistency-output.js +3 -3
- package/dist/commands/consistency-output.js.map +1 -1
- package/dist/commands/failed-loads-hint.d.ts +7 -0
- package/dist/commands/failed-loads-hint.d.ts.map +1 -0
- package/dist/commands/failed-loads-hint.js +16 -0
- package/dist/commands/failed-loads-hint.js.map +1 -0
- package/dist/commands/local-update.d.ts +22 -0
- package/dist/commands/local-update.d.ts.map +1 -0
- package/dist/commands/local-update.js +39 -0
- package/dist/commands/local-update.js.map +1 -0
- package/dist/commands/network-warning.d.ts.map +1 -1
- package/dist/commands/network-warning.js +2 -18
- package/dist/commands/network-warning.js.map +1 -1
- package/dist/commands/plan-snapshots.d.ts +23 -8
- package/dist/commands/plan-snapshots.d.ts.map +1 -1
- package/dist/commands/plan-snapshots.js +15 -9
- package/dist/commands/plan-snapshots.js.map +1 -1
- package/dist/commands/report-entries.d.ts +5 -2
- package/dist/commands/report-entries.d.ts.map +1 -1
- package/dist/commands/report-entries.js +63 -15
- package/dist/commands/report-entries.js.map +1 -1
- package/dist/commands/run-browser.d.ts +5 -5
- package/dist/commands/run-browser.d.ts.map +1 -1
- package/dist/commands/run-browser.js +1 -0
- package/dist/commands/run-browser.js.map +1 -1
- package/dist/commands/run-cli.d.ts +16 -5
- package/dist/commands/run-cli.d.ts.map +1 -1
- package/dist/commands/run-cli.js +74 -54
- package/dist/commands/run-cli.js.map +1 -1
- package/dist/commands/run-report.d.ts +3 -3
- package/dist/commands/run-report.d.ts.map +1 -1
- package/dist/commands/run-report.js +4 -2
- package/dist/commands/run-report.js.map +1 -1
- package/dist/commands/run-snapshots.d.ts +7 -4
- package/dist/commands/run-snapshots.d.ts.map +1 -1
- package/dist/commands/run-snapshots.js +49 -17
- package/dist/commands/run-snapshots.js.map +1 -1
- package/dist/commands/snapshot-result.d.ts +66 -9
- package/dist/commands/snapshot-result.d.ts.map +1 -1
- package/dist/commands/snapshot-result.js +46 -6
- package/dist/commands/snapshot-result.js.map +1 -1
- package/dist/commands/stop-message.d.ts.map +1 -1
- package/dist/commands/stop-message.js +6 -1
- package/dist/commands/stop-message.js.map +1 -1
- package/dist/commands/stopped-run.d.ts +10 -5
- package/dist/commands/stopped-run.d.ts.map +1 -1
- package/dist/commands/stopped-run.js +35 -22
- package/dist/commands/stopped-run.js.map +1 -1
- package/dist/commands/take-snapshot.d.ts +9 -6
- package/dist/commands/take-snapshot.d.ts.map +1 -1
- package/dist/commands/take-snapshot.js +16 -7
- package/dist/commands/take-snapshot.js.map +1 -1
- package/dist/commands/test-snapshot.d.ts +2 -2
- package/dist/commands/test-snapshot.d.ts.map +1 -1
- package/dist/commands/test-snapshot.js.map +1 -1
- package/dist/commands/update-baselines.d.ts.map +1 -1
- package/dist/commands/update-baselines.js +3 -2
- package/dist/commands/update-baselines.js.map +1 -1
- package/dist/commands/update-snapshot.d.ts +22 -4
- package/dist/commands/update-snapshot.d.ts.map +1 -1
- package/dist/commands/update-snapshot.js +79 -18
- package/dist/commands/update-snapshot.js.map +1 -1
- package/dist/config/checks.d.ts +26 -0
- package/dist/config/checks.d.ts.map +1 -1
- package/dist/config/checks.js +68 -6
- package/dist/config/checks.js.map +1 -1
- package/dist/config/define-config.d.ts +38 -2
- package/dist/config/define-config.d.ts.map +1 -1
- package/dist/config/define-config.js.map +1 -1
- package/dist/config/resolve-config.d.ts +15 -2
- package/dist/config/resolve-config.d.ts.map +1 -1
- package/dist/config/resolve-config.js +6 -0
- package/dist/config/resolve-config.js.map +1 -1
- package/dist/config/story-options.d.ts +32 -4
- package/dist/config/story-options.d.ts.map +1 -1
- package/dist/config/story-options.js +38 -7
- package/dist/config/story-options.js.map +1 -1
- package/dist/config/unrunnable-regexp.d.ts +22 -0
- package/dist/config/unrunnable-regexp.d.ts.map +1 -0
- package/dist/config/unrunnable-regexp.js +25 -0
- package/dist/config/unrunnable-regexp.js.map +1 -0
- package/dist/config/validate-config.d.ts.map +1 -1
- package/dist/config/validate-config.js +6 -21
- package/dist/config/validate-config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init/find-storybooks.d.ts +5 -0
- package/dist/init/find-storybooks.d.ts.map +1 -1
- package/dist/init/find-storybooks.js +8 -1
- package/dist/init/find-storybooks.js.map +1 -1
- package/dist/init/ignored-skill.d.ts +50 -0
- package/dist/init/ignored-skill.d.ts.map +1 -0
- package/dist/init/ignored-skill.js +61 -0
- package/dist/init/ignored-skill.js.map +1 -0
- package/dist/init/install.d.ts +24 -9
- package/dist/init/install.d.ts.map +1 -1
- package/dist/init/install.js +66 -26
- package/dist/init/install.js.map +1 -1
- package/dist/init/package-manager.d.ts +6 -0
- package/dist/init/package-manager.d.ts.map +1 -1
- package/dist/init/package-manager.js +4 -0
- package/dist/init/package-manager.js.map +1 -1
- package/dist/init/run-init.d.ts +17 -4
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +31 -11
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/workspace.d.ts +2 -0
- package/dist/init/workspace.d.ts.map +1 -1
- package/dist/init/workspace.js +2 -0
- package/dist/init/workspace.js.map +1 -1
- package/dist/page-errors/judge-page-errors.d.ts +50 -0
- package/dist/page-errors/judge-page-errors.d.ts.map +1 -0
- package/dist/page-errors/judge-page-errors.js +39 -0
- package/dist/page-errors/judge-page-errors.js.map +1 -0
- package/dist/page-errors/page-error-policy.d.ts +36 -0
- package/dist/page-errors/page-error-policy.d.ts.map +1 -0
- package/dist/page-errors/page-error-policy.js +15 -0
- package/dist/page-errors/page-error-policy.js.map +1 -0
- package/dist/real-network-requests/judge-real-requests.d.ts +26 -0
- package/dist/real-network-requests/judge-real-requests.d.ts.map +1 -0
- package/dist/real-network-requests/judge-real-requests.js +17 -0
- package/dist/real-network-requests/judge-real-requests.js.map +1 -0
- package/dist/real-network-requests/real-request-policy.d.ts +29 -0
- package/dist/real-network-requests/real-request-policy.d.ts.map +1 -0
- package/dist/real-network-requests/real-request-policy.js +10 -0
- package/dist/real-network-requests/real-request-policy.js.map +1 -0
- package/dist/real-network-requests/silenced-hosts.d.ts +9 -0
- package/dist/real-network-requests/silenced-hosts.d.ts.map +1 -0
- package/dist/real-network-requests/silenced-hosts.js +28 -0
- package/dist/real-network-requests/silenced-hosts.js.map +1 -0
- package/dist/report/report-document.d.ts +154 -9
- package/dist/report/report-document.d.ts.map +1 -1
- package/dist/report/report-document.js +1 -1
- package/dist/report/report-document.js.map +1 -1
- package/dist/report/report-folder.d.ts +7 -3
- package/dist/report/report-folder.d.ts.map +1 -1
- package/dist/report/report-folder.js +5 -5
- package/dist/report/report-folder.js.map +1 -1
- package/dist/reporter/end-block.d.ts +32 -3
- package/dist/reporter/end-block.d.ts.map +1 -1
- package/dist/reporter/end-block.js +55 -3
- package/dist/reporter/end-block.js.map +1 -1
- package/dist/reporter/page-errors-block.d.ts +52 -0
- package/dist/reporter/page-errors-block.d.ts.map +1 -0
- package/dist/reporter/page-errors-block.js +98 -0
- package/dist/reporter/page-errors-block.js.map +1 -0
- package/dist/reporter/real-requests-block.d.ts +33 -0
- package/dist/reporter/real-requests-block.d.ts.map +1 -0
- package/dist/reporter/real-requests-block.js +53 -0
- package/dist/reporter/real-requests-block.js.map +1 -0
- package/dist/step-summary/step-summary.d.ts +27 -7
- package/dist/step-summary/step-summary.d.ts.map +1 -1
- package/dist/step-summary/step-summary.js +107 -15
- package/dist/step-summary/step-summary.js.map +1 -1
- package/dist/storybook/options-encoding.d.ts +18 -5
- package/dist/storybook/options-encoding.d.ts.map +1 -1
- package/dist/storybook/options-encoding.js +12 -4
- package/dist/storybook/options-encoding.js.map +1 -1
- package/dist/storybook/options-read.d.ts +3 -2
- package/dist/storybook/options-read.d.ts.map +1 -1
- package/dist/storybook/options-read.js +17 -0
- package/dist/storybook/options-read.js.map +1 -1
- package/dist/storybook/read-stories.d.ts +15 -0
- package/dist/storybook/read-stories.d.ts.map +1 -1
- package/dist/storybook/read-stories.js +60 -14
- package/dist/storybook/read-stories.js.map +1 -1
- package/package.json +2 -1
- package/skill/SKILL.md +25 -7
|
@@ -3,6 +3,8 @@ import { displayPathOf } from '../report/display-path.js';
|
|
|
3
3
|
import { reportDir, } from '../report/report-document.js';
|
|
4
4
|
import { countsLineOf, orphanLabelOf } from './counts-line.js';
|
|
5
5
|
import { durationOf } from './duration.js';
|
|
6
|
+
import { pageErrorsBlockOf } from './page-errors-block.js';
|
|
7
|
+
import { realRequestsBlockOf } from './real-requests-block.js';
|
|
6
8
|
/**
|
|
7
9
|
* The statuses of the `test` entries that count as failures: the end block and the step summary list them.
|
|
8
10
|
*
|
|
@@ -54,13 +56,19 @@ function consoleLinesOf(entry) {
|
|
|
54
56
|
.slice(-listedConsoleCount)
|
|
55
57
|
.map(({ level, text }) => `console ${level}: ${text.split(/\r?\n/)[0]}`);
|
|
56
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Gives the path of an image in the report folder, relative to the folder the CLI runs in.
|
|
61
|
+
*/
|
|
62
|
+
function reportImagePathOf(context, image) {
|
|
63
|
+
return displayPathOf(context.cwd, join(context.configFolder, reportDir, image));
|
|
64
|
+
}
|
|
57
65
|
/**
|
|
58
66
|
* Gives a failure's lines: its name, then indented by two spaces its detail, the path of its visual diff when it has
|
|
59
67
|
* one, its hints, and for a broken story its last console errors and warnings.
|
|
60
68
|
*/
|
|
61
69
|
function failureLinesOf(entry, context) {
|
|
62
70
|
const { diff } = entry.images;
|
|
63
|
-
const diffLines = diff === null ? [] : [`diff: ${
|
|
71
|
+
const diffLines = diff === null ? [] : [`diff: ${reportImagePathOf(context, diff)}`];
|
|
64
72
|
const details = [
|
|
65
73
|
detailOf(entry, context),
|
|
66
74
|
...diffLines,
|
|
@@ -80,6 +88,20 @@ function failuresBlockOf(report, context) {
|
|
|
80
88
|
const heading = `── ${failures.length} ${failures.length === 1 ? 'failure' : 'failures'} ──`;
|
|
81
89
|
return [heading, ...failures.flatMap((entry) => failureLinesOf(entry, context))];
|
|
82
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Lists the snapshots that have page errors or stale expected page errors, whatever their status, in the report's
|
|
93
|
+
* order, by name, under a heading that says how many fail the run. Gives no line when none has either.
|
|
94
|
+
*/
|
|
95
|
+
function testPageErrorsBlockOf(report) {
|
|
96
|
+
return pageErrorsBlockOf(report.snapshots.map((entry) => ({ ...entry, name: entryNameOf(entry) })), 'test');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Lists the snapshots that have real network requests, whatever their status, in the report's order, by name, under a
|
|
100
|
+
* heading that says how many fail the run. Gives no line when none has any.
|
|
101
|
+
*/
|
|
102
|
+
function testRealRequestsBlockOf(report) {
|
|
103
|
+
return realRequestsBlockOf(report.snapshots.map((entry) => ({ ...entry, name: entryNameOf(entry) })));
|
|
104
|
+
}
|
|
83
105
|
/**
|
|
84
106
|
* Lists the snapshots that passed on a retry by name under a heading, each indented by two spaces. Gives no line when
|
|
85
107
|
* none did.
|
|
@@ -106,16 +128,46 @@ export function testCountsLineOf(counts) {
|
|
|
106
128
|
/**
|
|
107
129
|
* Builds the lines a `test` that captured ends with, from its report: the failures, each snapshot that differs, is
|
|
108
130
|
* broken or missing and each orphan, in the report's order, with the detail of each, the path of its visual diff, its
|
|
109
|
-
* hints and a broken story's last 5 console errors and warnings; then the snapshots
|
|
110
|
-
*
|
|
131
|
+
* hints and a broken story's last 5 console errors and warnings; then the snapshots with page errors, each with its
|
|
132
|
+
* first 5 page errors and their severity and its stale expected page errors; then the snapshots with real network
|
|
133
|
+
* requests, each with its first 5 hosts and their severity; then the snapshots that passed on a retry; then the counts
|
|
134
|
+
* and how long the run took.
|
|
111
135
|
*
|
|
112
136
|
* @public
|
|
113
137
|
*/
|
|
114
138
|
export function testEndLinesOf(report, context) {
|
|
115
139
|
return [
|
|
116
140
|
...failuresBlockOf(report, context),
|
|
141
|
+
...testPageErrorsBlockOf(report),
|
|
142
|
+
...testRealRequestsBlockOf(report),
|
|
117
143
|
...flakyBlockOf(report),
|
|
118
144
|
`${testCountsLineOf(report.counts)} · ${durationOf(context.elapsedMs)}`,
|
|
119
145
|
];
|
|
120
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Gives the line of a broken snapshot's image: the path of its visual diff or, with none, of its snapshot. Gives none
|
|
149
|
+
* when it has neither.
|
|
150
|
+
*/
|
|
151
|
+
function brokenImageLinesOf(images, context) {
|
|
152
|
+
if (images === undefined) {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
if (images.diff !== null) {
|
|
156
|
+
return [`diff: ${reportImagePathOf(context, images.diff)}`];
|
|
157
|
+
}
|
|
158
|
+
return images.snapshot === null ? [] : [`snapshot: ${reportImagePathOf(context, images.snapshot)}`];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Builds the lines of `update`'s broken snapshots, in the order given: `broken` and its name, then indented by two
|
|
162
|
+
* spaces the path of its visual diff or, with none, of its snapshot, relative to the folder the CLI runs in. A broken
|
|
163
|
+
* snapshot that keeps neither has its name alone. Gives no line when none is broken.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export function updateBrokenLinesOf(broken, context) {
|
|
168
|
+
return broken.flatMap(({ name, images }) => [
|
|
169
|
+
`broken ${name}`,
|
|
170
|
+
...brokenImageLinesOf(images, context).map((line) => ` ${line}`),
|
|
171
|
+
]);
|
|
172
|
+
}
|
|
121
173
|
//# sourceMappingURL=end-block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-block.js","sourceRoot":"","sources":["../../src/reporter/end-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"end-block.js","sourceRoot":"","sources":["../../src/reporter/end-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAGL,SAAS,GAIV,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAyC9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAyC,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;AAE/G;;GAEG;AACH,MAAM,mBAAmB,GAAkC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAE5E;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAE5B;;;GAGG;AACH,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAmB;IAClE,MAAM,UAAU,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAA;IAEnD,OAAO,GAAG,SAAS,KAAK,KAAK,IAAI,EAAE,GAAG,UAAU,EAAE,CAAA;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,KAAsB,EAAE,OAAwB;IAChE,QAAQ,KAAK,CAAC,MA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
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ReportPageError } from '../report/report-document.js';
|
|
2
|
+
/**
|
|
3
|
+
* A snapshot's page errors and the story's stale expected page errors, with the name the block lists it by.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface NamedPageErrors {
|
|
8
|
+
/**
|
|
9
|
+
* The snapshot's name, such as `web button--primary dark`.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Its page errors that no expected page error matches, each with its severity.
|
|
14
|
+
*/
|
|
15
|
+
pageErrors: readonly ReportPageError[];
|
|
16
|
+
/**
|
|
17
|
+
* The story's own expected page errors that matched none of its page errors, as written.
|
|
18
|
+
*/
|
|
19
|
+
staleExpectedPageErrors: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The command whose page errors are listed: `test` fails on those with severity `fail`, `update` never does.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type PageErrorsCommand = 'test' | 'update';
|
|
27
|
+
/**
|
|
28
|
+
* Gives a page error in one line: its kind in words, such as `uncaught error`, the first line of its text that isn't
|
|
29
|
+
* blank, as a stack trace spans several, and a load's network error or HTTP status after a `·`. A text with no such line
|
|
30
|
+
* leaves the kind alone.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function pageErrorTextOf({ kind, text, loadError }: Omit<ReportPageError, 'severity'>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Counts the snapshots' page errors in words, a `·` apart, leaving out a zero count: the snapshots that have page
|
|
37
|
+
* errors and, for `test`, how many of them fail the run, then the stale expected page errors, such as
|
|
38
|
+
* `3 snapshots with page errors, 2 of which fail the run · 1 stale expected page error`.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export declare function pageErrorCountsOf(snapshots: readonly Pick<NamedPageErrors, 'pageErrors' | 'staleExpectedPageErrors'>[], command: PageErrorsCommand): string;
|
|
43
|
+
/**
|
|
44
|
+
* Lists the snapshots that have page errors or stale expected page errors, in the order given, under a heading that
|
|
45
|
+
* counts the snapshots with page errors and, for `test`, how many fail the run, then the stale expected page errors:
|
|
46
|
+
* each by its name, then indented its first 5 page errors with
|
|
47
|
+
* their severity, how many more it has, and its stale expected page errors. Gives no line when none has either.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare function pageErrorsBlockOf(snapshots: readonly NamedPageErrors[], command: PageErrorsCommand): string[];
|
|
52
|
+
//# sourceMappingURL=page-errors-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-errors-block.d.ts","sourceRoot":"","sources":["../../src/reporter/page-errors-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAiBnE;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,EAAE,SAAS,eAAe,EAAE,CAAA;IACtC;;OAEG;IACH,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAA;CAC3C;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,MAAM,CAKpG;AA0BD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,yBAAyB,CAAC,EAAE,EACrF,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAQR;AA8BD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAa7G"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many of a snapshot's page errors the block lists.
|
|
3
|
+
*/
|
|
4
|
+
const listedPageErrorCount = 5;
|
|
5
|
+
/**
|
|
6
|
+
* The words each kind of page error is shown with.
|
|
7
|
+
*/
|
|
8
|
+
const kindWords = {
|
|
9
|
+
'console.error': 'console.error',
|
|
10
|
+
error: 'uncaught error',
|
|
11
|
+
unhandledrejection: 'unhandled rejection',
|
|
12
|
+
load: 'failed load',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Gives a page error in one line: its kind in words, such as `uncaught error`, the first line of its text that isn't
|
|
16
|
+
* blank, as a stack trace spans several, and a load's network error or HTTP status after a `·`. A text with no such line
|
|
17
|
+
* leaves the kind alone.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export function pageErrorTextOf({ kind, text, loadError }) {
|
|
22
|
+
const firstLine = text.split(/\r?\n/).find((line) => line.trim() !== '');
|
|
23
|
+
const status = loadError === undefined ? '' : ` · ${loadError}`;
|
|
24
|
+
return `${[kindWords[kind], ...(firstLine === undefined ? [] : [firstLine])].join(' ')}${status}`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Counts the snapshots with page errors in words, such as `3 snapshots with page errors, 2 of which fail the run`: for
|
|
28
|
+
* `test`, how many of them have a page error that fails it, all of them, some, or none; `update` never fails on page
|
|
29
|
+
* errors.
|
|
30
|
+
*/
|
|
31
|
+
function snapshotsWithPageErrorsOf(snapshots, command) {
|
|
32
|
+
const count = snapshots.length;
|
|
33
|
+
const failing = command === 'test'
|
|
34
|
+
? snapshots.filter(({ pageErrors }) => pageErrors.some(({ severity }) => severity === 'fail')).length
|
|
35
|
+
: 0;
|
|
36
|
+
const counted = `${count} ${count === 1 ? 'snapshot' : 'snapshots'} with page errors`;
|
|
37
|
+
const fail = failing === 1 ? 'fails' : 'fail';
|
|
38
|
+
if (failing === 0) {
|
|
39
|
+
return counted;
|
|
40
|
+
}
|
|
41
|
+
return failing === count ? `${counted}, which ${fail} the run` : `${counted}, ${failing} of which ${fail} the run`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Counts the snapshots' page errors in words, a `·` apart, leaving out a zero count: the snapshots that have page
|
|
45
|
+
* errors and, for `test`, how many of them fail the run, then the stale expected page errors, such as
|
|
46
|
+
* `3 snapshots with page errors, 2 of which fail the run · 1 stale expected page error`.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export function pageErrorCountsOf(snapshots, command) {
|
|
51
|
+
const withErrors = snapshots.filter(({ pageErrors }) => pageErrors.length > 0);
|
|
52
|
+
const stale = snapshots.reduce((sum, { staleExpectedPageErrors }) => sum + staleExpectedPageErrors.length, 0);
|
|
53
|
+
return [
|
|
54
|
+
...(withErrors.length === 0 ? [] : [snapshotsWithPageErrorsOf(withErrors, command)]),
|
|
55
|
+
...(stale === 0 ? [] : [`${stale} stale expected ${stale === 1 ? 'page error' : 'page errors'}`]),
|
|
56
|
+
].join(' · ');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gives a page error's severity as its line shows it: for `test`, `fail` or `warn`; for `update`, which never fails on
|
|
60
|
+
* page errors, `fails test` or `warn`.
|
|
61
|
+
*/
|
|
62
|
+
function severityOf({ severity }, command) {
|
|
63
|
+
return command === 'update' && severity === 'fail' ? 'fails test' : severity;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gives a snapshot's lines: its name, then indented by two spaces its first 5 page errors, each with its severity, how
|
|
67
|
+
* many more it has, and its stale expected page errors.
|
|
68
|
+
*/
|
|
69
|
+
function snapshotLinesOf({ name, pageErrors, staleExpectedPageErrors }, command) {
|
|
70
|
+
const more = pageErrors.length - listedPageErrorCount;
|
|
71
|
+
const details = [
|
|
72
|
+
...pageErrors
|
|
73
|
+
.slice(0, listedPageErrorCount)
|
|
74
|
+
.map((error) => `page error (${severityOf(error, command)}): ${pageErrorTextOf(error)}`),
|
|
75
|
+
...(more > 0 ? [`…and ${more} more ${more === 1 ? 'page error' : 'page errors'}`] : []),
|
|
76
|
+
...staleExpectedPageErrors.map((entry) => `stale expected page error: ${entry}`),
|
|
77
|
+
];
|
|
78
|
+
return [name, ...details.map((line) => ` ${line}`)];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Lists the snapshots that have page errors or stale expected page errors, in the order given, under a heading that
|
|
82
|
+
* counts the snapshots with page errors and, for `test`, how many fail the run, then the stale expected page errors:
|
|
83
|
+
* each by its name, then indented its first 5 page errors with
|
|
84
|
+
* their severity, how many more it has, and its stale expected page errors. Gives no line when none has either.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export function pageErrorsBlockOf(snapshots, command) {
|
|
89
|
+
const listed = snapshots.filter(({ pageErrors, staleExpectedPageErrors }) => pageErrors.length > 0 || staleExpectedPageErrors.length > 0);
|
|
90
|
+
if (listed.length === 0) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
return [
|
|
94
|
+
`── ${pageErrorCountsOf(listed, command)} ──`,
|
|
95
|
+
...listed.flatMap((snapshot) => snapshotLinesOf(snapshot, command)),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=page-errors-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-errors-block.js","sourceRoot":"","sources":["../../src/reporter/page-errors-block.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAE9B;;GAEG;AACH,MAAM,SAAS,GAA4C;IACzD,eAAe,EAAE,eAAe;IAChC,KAAK,EAAE,gBAAgB;IACvB,kBAAkB,EAAE,qBAAqB;IACzC,IAAI,EAAE,aAAa;CAC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,OAAO,CAAC,CAAC;KACpE,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReportRealRequest } from '../report/report-document.js';
|
|
2
|
+
/**
|
|
3
|
+
* A snapshot's real network requests, with the name the block lists it by.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface NamedRealRequests {
|
|
8
|
+
/**
|
|
9
|
+
* The snapshot's name, such as `web button--primary dark`.
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The hosts its pages sent real network requests to, which `silenceHosts` doesn't match, each with its severity.
|
|
14
|
+
*/
|
|
15
|
+
realRequests: readonly ReportRealRequest[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Counts the snapshots with real network requests in words, and how many of them have a host that fails the run: all
|
|
19
|
+
* of them, some, or none, such as `3 snapshots with real network requests, 2 of which fail the run`. Snapshots with
|
|
20
|
+
* none aren't counted.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare function realRequestCountsOf(snapshots: readonly Pick<NamedRealRequests, 'realRequests'>[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Lists the snapshots that have real network requests, in the order given, under a heading that counts them and says
|
|
27
|
+
* how many fail the run: each by its name, then indented its first 5 hosts with their severity and how many more it
|
|
28
|
+
* has. Gives no line when none has any.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare function realRequestsBlockOf(snapshots: readonly NamedRealRequests[]): string[];
|
|
33
|
+
//# sourceMappingURL=real-requests-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-requests-block.d.ts","sourceRoot":"","sources":["../../src/reporter/real-requests-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAOrE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,YAAY,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,EAAE,GAAG,MAAM,CAczG;AAkBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAQrF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many of a snapshot's hosts the block lists.
|
|
3
|
+
*/
|
|
4
|
+
const listedHostCount = 5;
|
|
5
|
+
/**
|
|
6
|
+
* Counts the snapshots with real network requests in words, and how many of them have a host that fails the run: all
|
|
7
|
+
* of them, some, or none, such as `3 snapshots with real network requests, 2 of which fail the run`. Snapshots with
|
|
8
|
+
* none aren't counted.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export function realRequestCountsOf(snapshots) {
|
|
13
|
+
const withRequests = snapshots.filter(({ realRequests }) => realRequests.length > 0);
|
|
14
|
+
const count = withRequests.length;
|
|
15
|
+
const failing = withRequests.filter(({ realRequests }) => realRequests.some(({ severity }) => severity === 'fail'));
|
|
16
|
+
const counted = `${count} ${count === 1 ? 'snapshot' : 'snapshots'} with real network requests`;
|
|
17
|
+
const fail = failing.length === 1 ? 'fails' : 'fail';
|
|
18
|
+
if (failing.length === 0) {
|
|
19
|
+
return counted;
|
|
20
|
+
}
|
|
21
|
+
return failing.length === count
|
|
22
|
+
? `${counted}, which ${fail} the run`
|
|
23
|
+
: `${counted}, ${failing.length} of which ${fail} the run`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gives a snapshot's lines: its name, then indented by two spaces its first 5 hosts, each with its severity, and how
|
|
27
|
+
* many more it has.
|
|
28
|
+
*/
|
|
29
|
+
function snapshotLinesOf({ name, realRequests }) {
|
|
30
|
+
const more = realRequests.length - listedHostCount;
|
|
31
|
+
const details = [
|
|
32
|
+
...realRequests
|
|
33
|
+
.slice(0, listedHostCount)
|
|
34
|
+
.map(({ host, severity }) => `real network request (${severity}): ${host}`),
|
|
35
|
+
...(more > 0 ? [`…and ${more} more ${more === 1 ? 'host' : 'hosts'}`] : []),
|
|
36
|
+
];
|
|
37
|
+
return [name, ...details.map((line) => ` ${line}`)];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Lists the snapshots that have real network requests, in the order given, under a heading that counts them and says
|
|
41
|
+
* how many fail the run: each by its name, then indented its first 5 hosts with their severity and how many more it
|
|
42
|
+
* has. Gives no line when none has any.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export function realRequestsBlockOf(snapshots) {
|
|
47
|
+
const listed = snapshots.filter(({ realRequests }) => realRequests.length > 0);
|
|
48
|
+
if (listed.length === 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return [`── ${realRequestCountsOf(listed)} ──`, ...listed.flatMap(snapshotLinesOf)];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=real-requests-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-requests-block.js","sourceRoot":"","sources":["../../src/reporter/real-requests-block.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,CAAA;AAkBzB;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAA6D;IAC/F,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACpF,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAA;IACjC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,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AAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAuC;IACzE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAE9E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,CAAC,MAAM,mBAAmB,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;AACrF,CAAC"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { Report } from '../report/report-document.js';
|
|
2
|
+
/**
|
|
3
|
+
* How the person updates the baselines on their machine, which a failing `test`'s summary says.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface LocalUpdate {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the project's script whose command is exactly `visual-check update`, such as `visual:update`, or
|
|
10
|
+
* `undefined` when none is.
|
|
11
|
+
*/
|
|
12
|
+
script: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the browser runs in Docker on the person's machine: every platform but `host`.
|
|
15
|
+
*/
|
|
16
|
+
docker: boolean;
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* The step summary couldn't be written, such as for a folder that doesn't exist or a path that is a folder.
|
|
4
20
|
*
|
|
@@ -24,22 +40,26 @@ export declare class StepSummaryError extends Error {
|
|
|
24
40
|
}
|
|
25
41
|
/**
|
|
26
42
|
* Builds the run's step summary in Markdown, under `budgetBytes` in UTF-8: a heading naming the version, the command,
|
|
27
|
-
* the shard and whether only the consistency check ran, then the counts, the flaky snapshots, at most 100,
|
|
43
|
+
* the shard and whether only the consistency check ran, then the counts, the flaky snapshots, at most 100, the
|
|
44
|
+
* snapshots with page errors, how many and the first 5 with the first of each, for `test` the snapshots with real
|
|
45
|
+
* network requests, how many and the first 5 with their first 3 hosts, then, for a `test` with a snapshot that
|
|
46
|
+
* differs, a missing baseline or an orphan and a `localUpdate` given, how to update the baselines locally, and a table
|
|
28
47
|
* of the failures in the report's order, the names and cells escaped. The table keeps its first rows that fit, and a
|
|
29
|
-
* note says how many it leaves out. A run that exited 2 gives the heading and its error instead, cut to fit with a
|
|
30
|
-
*
|
|
31
|
-
*
|
|
48
|
+
* note says how many it leaves out. A run that exited 2 gives the heading and its error instead, cut to fit with a note
|
|
49
|
+
* that says so, or the heading alone when not even the note fits. Gives `''` when even the part before the table's
|
|
50
|
+
* rows, or the heading, doesn't fit.
|
|
32
51
|
*
|
|
33
52
|
* @public
|
|
34
53
|
*/
|
|
35
|
-
export declare function stepSummaryOf(report: Report, budgetBytes: number): string;
|
|
54
|
+
export declare function stepSummaryOf(report: Report, budgetBytes: number, localUpdate?: LocalUpdate): string;
|
|
36
55
|
/**
|
|
37
56
|
* Appends the run's step summary to the file at `path`, creating it when it doesn't exist, so the file stays under
|
|
38
57
|
* GitHub's 1 MiB with 1 KiB left for the Action: the budget counts what the file already holds. After what it holds,
|
|
39
|
-
* a blank line comes first, so the summary's heading is one.
|
|
58
|
+
* a blank line comes first, so the summary's heading is one. A failing `test` with a `localUpdate` says how to update
|
|
59
|
+
* the baselines locally. Writes nothing when no summary fits.
|
|
40
60
|
*
|
|
41
61
|
* @throws {StepSummaryError} When the file can't be read or written.
|
|
42
62
|
* @public
|
|
43
63
|
*/
|
|
44
|
-
export declare function appendStepSummary(path: string, report: Report): Promise<void>;
|
|
64
|
+
export declare function appendStepSummary(path: string, report: Report, localUpdate?: LocalUpdate): Promise<void>;
|
|
45
65
|
//# sourceMappingURL=step-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-summary.d.ts","sourceRoot":"","sources":["../../src/step-summary/step-summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"step-summary.d.ts","sourceRoot":"","sources":["../../src/step-summary/step-summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,8BAA8B,CAAA;AAyD7E;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB;AAYD;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC;;OAEG;IACM,IAAI,SAAqB;IAElC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAMvC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAuBpG;AAqQD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9G"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { appendFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { countsLineOf } from '../reporter/counts-line.js';
|
|
3
3
|
import { failureStatuses, testCountsLineOf } from '../reporter/end-block.js';
|
|
4
|
+
import { pageErrorCountsOf, pageErrorTextOf } from '../reporter/page-errors-block.js';
|
|
5
|
+
import { realRequestCountsOf } from '../reporter/real-requests-block.js';
|
|
4
6
|
import { systemReasonOf } from '../system-error/system-reason.js';
|
|
5
7
|
/**
|
|
6
8
|
* The most a step summary file may hold, in bytes: GitHub's 1 MiB per step.
|
|
@@ -14,6 +16,18 @@ const actionBytes = 1024;
|
|
|
14
16
|
* The most flaky snapshots the summary names.
|
|
15
17
|
*/
|
|
16
18
|
const listedFlakyCount = 100;
|
|
19
|
+
/**
|
|
20
|
+
* The most snapshots with page errors the summary names.
|
|
21
|
+
*/
|
|
22
|
+
const listedPageErrorSnapshotCount = 5;
|
|
23
|
+
/**
|
|
24
|
+
* The most snapshots with real network requests the summary names.
|
|
25
|
+
*/
|
|
26
|
+
const listedRealRequestSnapshotCount = 5;
|
|
27
|
+
/**
|
|
28
|
+
* The most hosts the summary names for one snapshot with real network requests.
|
|
29
|
+
*/
|
|
30
|
+
const listedHostCount = 3;
|
|
17
31
|
/**
|
|
18
32
|
* What starts a summary appended after what the file already holds: a blank line, so its heading is one.
|
|
19
33
|
*/
|
|
@@ -26,6 +40,10 @@ const errorCutNote = "_The error is cut, to keep this summary under GitHub's 1 M
|
|
|
26
40
|
* The failures table's head: its column names and the line under them.
|
|
27
41
|
*/
|
|
28
42
|
const tableHead = '| Storybook | Story | Mode | Status | Message |\n| --- | --- | --- | --- | --- |';
|
|
43
|
+
/**
|
|
44
|
+
* The `test` statuses `update` fixes, which the note on updating the baselines locally answers.
|
|
45
|
+
*/
|
|
46
|
+
const updatableStatuses = ['differs', 'missing', 'orphan'];
|
|
29
47
|
/**
|
|
30
48
|
* The step summary couldn't be written, such as for a folder that doesn't exist or a path that is a folder.
|
|
31
49
|
*
|
|
@@ -56,25 +74,53 @@ export class StepSummaryError extends Error {
|
|
|
56
74
|
}
|
|
57
75
|
/**
|
|
58
76
|
* Builds the run's step summary in Markdown, under `budgetBytes` in UTF-8: a heading naming the version, the command,
|
|
59
|
-
* the shard and whether only the consistency check ran, then the counts, the flaky snapshots, at most 100,
|
|
77
|
+
* the shard and whether only the consistency check ran, then the counts, the flaky snapshots, at most 100, the
|
|
78
|
+
* snapshots with page errors, how many and the first 5 with the first of each, for `test` the snapshots with real
|
|
79
|
+
* network requests, how many and the first 5 with their first 3 hosts, then, for a `test` with a snapshot that
|
|
80
|
+
* differs, a missing baseline or an orphan and a `localUpdate` given, how to update the baselines locally, and a table
|
|
60
81
|
* of the failures in the report's order, the names and cells escaped. The table keeps its first rows that fit, and a
|
|
61
|
-
* note says how many it leaves out. A run that exited 2 gives the heading and its error instead, cut to fit with a
|
|
62
|
-
*
|
|
63
|
-
*
|
|
82
|
+
* note says how many it leaves out. A run that exited 2 gives the heading and its error instead, cut to fit with a note
|
|
83
|
+
* that says so, or the heading alone when not even the note fits. Gives `''` when even the part before the table's
|
|
84
|
+
* rows, or the heading, doesn't fit.
|
|
64
85
|
*
|
|
65
86
|
* @public
|
|
66
87
|
*/
|
|
67
|
-
export function stepSummaryOf(report, budgetBytes) {
|
|
88
|
+
export function stepSummaryOf(report, budgetBytes, localUpdate) {
|
|
68
89
|
const heading = headingOf(report);
|
|
69
90
|
if (report.error !== null) {
|
|
70
91
|
return errorSummaryOf(heading, report.error.message, budgetBytes);
|
|
71
92
|
}
|
|
72
|
-
const blocks = [
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
const blocks = [
|
|
94
|
+
heading,
|
|
95
|
+
countsOf(report),
|
|
96
|
+
...flakyBlockOf(report),
|
|
97
|
+
...pageErrorSnapshotsBlockOf(report),
|
|
98
|
+
...realRequestSnapshotsBlockOf(report),
|
|
99
|
+
];
|
|
100
|
+
const failures = failuresOf(report);
|
|
101
|
+
if (failures.length === 0) {
|
|
75
102
|
return withinBudget(`${blocks.join('\n\n')}\n`, budgetBytes);
|
|
76
103
|
}
|
|
77
|
-
|
|
104
|
+
const head = [...blocks, ...updateNoteOf(failures, localUpdate), '**Failures**', tableHead].join('\n\n');
|
|
105
|
+
return failuresSummaryOf(head, failures.map(rowOf), report, budgetBytes);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Gives the note on updating the baselines locally, when the failures the summary lists hold a snapshot that differs,
|
|
109
|
+
* a missing baseline or an orphan, the failures `update` fixes. An `update`'s failures are broken stories only, so it
|
|
110
|
+
* never gets one. The note names the project's script, else `visual-check update`, and asks for Docker unless the
|
|
111
|
+
* browser runs on the host. Gives no note with no `localUpdate`.
|
|
112
|
+
*/
|
|
113
|
+
function updateNoteOf(failures, localUpdate) {
|
|
114
|
+
if (localUpdate === undefined || !failures.some((entry) => updatableStatuses.includes(entry.status))) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const running = localUpdate.docker ? 'Storybook running and Docker up' : 'Storybook running';
|
|
118
|
+
// The script's name holds no backtick or line break, the only characters that would break the code span.
|
|
119
|
+
const run = localUpdate.script === undefined ? '`visual-check update`' : `the \`${localUpdate.script}\` script`;
|
|
120
|
+
return [
|
|
121
|
+
`If the changes are intended, update the baselines on your machine: with ${running}, run ${run}, ` +
|
|
122
|
+
'then commit the baselines it writes and deletes.',
|
|
123
|
+
];
|
|
78
124
|
}
|
|
79
125
|
/**
|
|
80
126
|
* Gives the summary of a run that exited 2: the heading, then its error as an indented code block, so nothing in it
|
|
@@ -146,12 +192,57 @@ function flakyBlockOf(report) {
|
|
|
146
192
|
if (flaky.length === 0) {
|
|
147
193
|
return [];
|
|
148
194
|
}
|
|
149
|
-
const names = flaky.slice(0, listedFlakyCount).map((
|
|
150
|
-
return `- ${[storybook, story ?? id, ...(mode === null ? [] : [mode])].map(inlineTextOf).join(' · ')}`;
|
|
151
|
-
});
|
|
195
|
+
const names = flaky.slice(0, listedFlakyCount).map((entry) => `- ${entryNameOf(entry)}`);
|
|
152
196
|
const more = flaky.length > listedFlakyCount ? [`- …and ${flaky.length - listedFlakyCount} more`] : [];
|
|
153
197
|
return ['**Flaky snapshots**', [...names, ...more].join('\n')];
|
|
154
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Gives the page errors block: how many snapshots have page errors and, for `test`, how many of them fail the run, then
|
|
201
|
+
* how many stale expected page errors there are, then the first 5 snapshots that have either, whatever their status,
|
|
202
|
+
* each with its first page error, else its first stale expected page error, then how many more there are. Gives no
|
|
203
|
+
* block when no snapshot has either.
|
|
204
|
+
*/
|
|
205
|
+
function pageErrorSnapshotsBlockOf(report) {
|
|
206
|
+
const entries = report.snapshots;
|
|
207
|
+
const listed = entries.filter((entry) => entry.pageErrors.length > 0 || entry.staleExpectedPageErrors.length > 0);
|
|
208
|
+
if (listed.length === 0) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
const items = listed.slice(0, listedPageErrorSnapshotCount).map((entry) => {
|
|
212
|
+
const [first] = entry.pageErrors;
|
|
213
|
+
const problem = first === undefined ? `stale expected page error ${entry.staleExpectedPageErrors[0]}` : pageErrorTextOf(first);
|
|
214
|
+
return `- ${entryNameOf(entry)}: ${inlineTextOf(problem)}`;
|
|
215
|
+
});
|
|
216
|
+
const more = listed.length > listedPageErrorSnapshotCount ? [`- …and ${listed.length - listedPageErrorSnapshotCount} more`] : [];
|
|
217
|
+
return ['**Page errors**', pageErrorCountsOf(entries, report.command), [...items, ...more].join('\n')];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Gives the real network requests block of a `test`: how many snapshots have real network requests and how many of
|
|
221
|
+
* them fail the run, then the first 5, whatever their status, each with its first 3 hosts, then how many more there
|
|
222
|
+
* are. Gives no block when no snapshot has any, and none for `update`, which lists hosts as warnings instead.
|
|
223
|
+
*/
|
|
224
|
+
function realRequestSnapshotsBlockOf(report) {
|
|
225
|
+
const listed = report.command === 'test' ? report.snapshots.filter((entry) => entry.realRequests.length > 0) : [];
|
|
226
|
+
if (listed.length === 0) {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
const items = listed.slice(0, listedRealRequestSnapshotCount).map((entry) => {
|
|
230
|
+
const hosts = entry.realRequests.slice(0, listedHostCount).map(({ host }) => host);
|
|
231
|
+
const more = entry.realRequests.length > listedHostCount ? ', …' : '';
|
|
232
|
+
return `- ${entryNameOf(entry)}: ${inlineTextOf(hosts.join(', '))}${more}`;
|
|
233
|
+
});
|
|
234
|
+
const more = listed.length > listedRealRequestSnapshotCount
|
|
235
|
+
? [`- …and ${listed.length - listedRealRequestSnapshotCount} more`]
|
|
236
|
+
: [];
|
|
237
|
+
return ['**Real network requests**', realRequestCountsOf(listed), [...items, ...more].join('\n')];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Names an entry by its Storybook, its story ID or an orphan's stem, and its mode when it has one, each escaped, a `·`
|
|
241
|
+
* apart.
|
|
242
|
+
*/
|
|
243
|
+
function entryNameOf({ storybook, story, id, mode }) {
|
|
244
|
+
return [storybook, story ?? id, ...(mode === null ? [] : [mode])].map(inlineTextOf).join(' · ');
|
|
245
|
+
}
|
|
155
246
|
/**
|
|
156
247
|
* Gives the entries the failures table lists, in the report's order: for `test` the snapshots that differ, the broken
|
|
157
248
|
* and missing ones and the orphans; for `update` the broken stories.
|
|
@@ -224,16 +315,17 @@ function byteLengthOf(text) {
|
|
|
224
315
|
/**
|
|
225
316
|
* Appends the run's step summary to the file at `path`, creating it when it doesn't exist, so the file stays under
|
|
226
317
|
* GitHub's 1 MiB with 1 KiB left for the Action: the budget counts what the file already holds. After what it holds,
|
|
227
|
-
* a blank line comes first, so the summary's heading is one.
|
|
318
|
+
* a blank line comes first, so the summary's heading is one. A failing `test` with a `localUpdate` says how to update
|
|
319
|
+
* the baselines locally. Writes nothing when no summary fits.
|
|
228
320
|
*
|
|
229
321
|
* @throws {StepSummaryError} When the file can't be read or written.
|
|
230
322
|
* @public
|
|
231
323
|
*/
|
|
232
|
-
export async function appendStepSummary(path, report) {
|
|
324
|
+
export async function appendStepSummary(path, report, localUpdate) {
|
|
233
325
|
// GitHub gives each step its own summary file, so nothing else appends between the size check and the write.
|
|
234
326
|
const existingBytes = await sizeOf(path);
|
|
235
327
|
const start = existingBytes === 0 ? '' : separator;
|
|
236
|
-
const summary = stepSummaryOf(report, stepLimitBytes - actionBytes - existingBytes - byteLengthOf(start));
|
|
328
|
+
const summary = stepSummaryOf(report, stepLimitBytes - actionBytes - existingBytes - byteLengthOf(start), localUpdate);
|
|
237
329
|
if (summary === '') {
|
|
238
330
|
return;
|
|
239
331
|
}
|