visual-ai-assertions 0.2.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/README.md +487 -0
- package/dist/index.cjs +1416 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +839 -0
- package/dist/index.d.ts +839 -0
- package/dist/index.js +1349 -0
- package/dist/index.js.map +1 -0
- package/package.json +112 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Supported provider identifiers for configuring `visualAI()`. */
|
|
4
|
+
declare const Provider: {
|
|
5
|
+
readonly ANTHROPIC: "anthropic";
|
|
6
|
+
readonly OPENAI: "openai";
|
|
7
|
+
readonly GOOGLE: "google";
|
|
8
|
+
};
|
|
9
|
+
/** Known model names grouped by provider. */
|
|
10
|
+
declare const Model: {
|
|
11
|
+
readonly Anthropic: {
|
|
12
|
+
readonly OPUS_4_6: "claude-opus-4-6";
|
|
13
|
+
readonly SONNET_4_6: "claude-sonnet-4-6";
|
|
14
|
+
readonly HAIKU_4_5: "claude-haiku-4-5";
|
|
15
|
+
};
|
|
16
|
+
readonly OpenAI: {
|
|
17
|
+
readonly GPT_5_4: "gpt-5.4";
|
|
18
|
+
readonly GPT_5_4_PRO: "gpt-5.4-pro";
|
|
19
|
+
readonly GPT_5_2: "gpt-5.2";
|
|
20
|
+
readonly GPT_5_MINI: "gpt-5-mini";
|
|
21
|
+
};
|
|
22
|
+
readonly Google: {
|
|
23
|
+
readonly GEMINI_3_1_PRO_PREVIEW: "gemini-3.1-pro-preview";
|
|
24
|
+
readonly GEMINI_3_FLASH_PREVIEW: "gemini-3-flash-preview";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** Union of all built-in model name literals exposed by `Model`. */
|
|
28
|
+
type KnownModelName = (typeof Model.Anthropic)[keyof typeof Model.Anthropic] | (typeof Model.OpenAI)[keyof typeof Model.OpenAI] | (typeof Model.Google)[keyof typeof Model.Google];
|
|
29
|
+
/** Default model selection used when a caller omits `config.model`. */
|
|
30
|
+
declare const DEFAULT_MODELS: {
|
|
31
|
+
readonly anthropic: "claude-sonnet-4-6";
|
|
32
|
+
readonly openai: "gpt-5-mini";
|
|
33
|
+
readonly google: "gemini-3-flash-preview";
|
|
34
|
+
};
|
|
35
|
+
/** List of accepted provider names for validation and public consumption. */
|
|
36
|
+
declare const VALID_PROVIDERS: readonly ProviderName[];
|
|
37
|
+
/** Built-in content checks available through `client.content()`. */
|
|
38
|
+
declare const Content: {
|
|
39
|
+
/** Detects Lorem ipsum, TODO, TBD, and similar placeholder text */
|
|
40
|
+
readonly PLACEHOLDER_TEXT: "placeholder-text";
|
|
41
|
+
/** Detects error messages, banners, stack traces, or error codes */
|
|
42
|
+
readonly ERROR_MESSAGES: "error-messages";
|
|
43
|
+
/** Detects broken image icons or failed-to-load image indicators */
|
|
44
|
+
readonly BROKEN_IMAGES: "broken-images";
|
|
45
|
+
/** Detects UI elements that unintentionally overlap and obscure content */
|
|
46
|
+
readonly OVERLAPPING_ELEMENTS: "overlapping-elements";
|
|
47
|
+
};
|
|
48
|
+
/** Built-in layout checks available through `client.layout()`. */
|
|
49
|
+
declare const Layout: {
|
|
50
|
+
/** Detects elements that unintentionally overlap each other */
|
|
51
|
+
readonly OVERLAP: "overlap";
|
|
52
|
+
/** Detects content cut off or extending beyond container boundaries */
|
|
53
|
+
readonly OVERFLOW: "overflow";
|
|
54
|
+
/** Detects inconsistent alignment of text, images, and UI components */
|
|
55
|
+
readonly ALIGNMENT: "alignment";
|
|
56
|
+
};
|
|
57
|
+
/** Built-in accessibility checks available through `client.accessibility()`. */
|
|
58
|
+
declare const Accessibility: {
|
|
59
|
+
/** Detects insufficient color contrast between text and backgrounds */
|
|
60
|
+
readonly CONTRAST: "contrast";
|
|
61
|
+
/** Detects text that is cut off, overlapping, too small, or obscured */
|
|
62
|
+
readonly READABILITY: "readability";
|
|
63
|
+
/** Detects interactive elements that are not visually distinct */
|
|
64
|
+
readonly INTERACTIVE_VISIBILITY: "interactive-visibility";
|
|
65
|
+
};
|
|
66
|
+
/** Union of all built-in content check names. */
|
|
67
|
+
type ContentCheckName = (typeof Content)[keyof typeof Content];
|
|
68
|
+
/** Union of all built-in layout check names. */
|
|
69
|
+
type LayoutCheckName = (typeof Layout)[keyof typeof Layout];
|
|
70
|
+
/** Union of all built-in accessibility check names. */
|
|
71
|
+
type AccessibilityCheckName = (typeof Accessibility)[keyof typeof Accessibility];
|
|
72
|
+
|
|
73
|
+
/** Zod schema for issue severity levels returned by checks and questions. */
|
|
74
|
+
declare const IssuePrioritySchema: z.ZodEnum<["critical", "major", "minor"]>;
|
|
75
|
+
/** Severity level for a detected visual issue. */
|
|
76
|
+
type IssuePriority = z.infer<typeof IssuePrioritySchema>;
|
|
77
|
+
/** Zod schema for the categories assigned to detected visual issues. */
|
|
78
|
+
declare const IssueCategorySchema: z.ZodEnum<["accessibility", "missing-element", "layout", "content", "styling", "functionality", "performance", "other"]>;
|
|
79
|
+
/** Category assigned to a detected visual issue. */
|
|
80
|
+
type IssueCategory = z.infer<typeof IssueCategorySchema>;
|
|
81
|
+
/** Zod schema for a structured issue reported by the model. */
|
|
82
|
+
declare const IssueSchema: z.ZodObject<{
|
|
83
|
+
priority: z.ZodEnum<["critical", "major", "minor"]>;
|
|
84
|
+
category: z.ZodEnum<["accessibility", "missing-element", "layout", "content", "styling", "functionality", "performance", "other"]>;
|
|
85
|
+
description: z.ZodString;
|
|
86
|
+
suggestion: z.ZodString;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
priority: "critical" | "major" | "minor";
|
|
89
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
90
|
+
description: string;
|
|
91
|
+
suggestion: string;
|
|
92
|
+
}, {
|
|
93
|
+
priority: "critical" | "major" | "minor";
|
|
94
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
95
|
+
description: string;
|
|
96
|
+
suggestion: string;
|
|
97
|
+
}>;
|
|
98
|
+
/** Structured issue reported by a visual check or question. */
|
|
99
|
+
type Issue = z.infer<typeof IssueSchema>;
|
|
100
|
+
/** Zod schema for model confidence labels on statement-level results. */
|
|
101
|
+
declare const ConfidenceSchema: z.ZodEnum<["high", "medium", "low"]>;
|
|
102
|
+
/** Confidence level attached to a statement result. */
|
|
103
|
+
type Confidence = z.infer<typeof ConfidenceSchema>;
|
|
104
|
+
/** Zod schema for an individual statement evaluation within `check()`. */
|
|
105
|
+
declare const StatementResultSchema: z.ZodObject<{
|
|
106
|
+
statement: z.ZodString;
|
|
107
|
+
pass: z.ZodBoolean;
|
|
108
|
+
reasoning: z.ZodString;
|
|
109
|
+
confidence: z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
statement: string;
|
|
112
|
+
pass: boolean;
|
|
113
|
+
reasoning: string;
|
|
114
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
115
|
+
}, {
|
|
116
|
+
statement: string;
|
|
117
|
+
pass: boolean;
|
|
118
|
+
reasoning: string;
|
|
119
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
/** Outcome of a single statement evaluated by `check()`. */
|
|
122
|
+
type StatementResult = z.infer<typeof StatementResultSchema>;
|
|
123
|
+
/** Zod schema for token and latency metadata attached to API calls. */
|
|
124
|
+
declare const UsageInfoSchema: z.ZodObject<{
|
|
125
|
+
inputTokens: z.ZodNumber;
|
|
126
|
+
outputTokens: z.ZodNumber;
|
|
127
|
+
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
inputTokens: number;
|
|
131
|
+
outputTokens: number;
|
|
132
|
+
estimatedCost?: number | undefined;
|
|
133
|
+
durationSeconds?: number | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
inputTokens: number;
|
|
136
|
+
outputTokens: number;
|
|
137
|
+
estimatedCost?: number | undefined;
|
|
138
|
+
durationSeconds?: number | undefined;
|
|
139
|
+
}>;
|
|
140
|
+
/** Token usage and optional cost/latency metadata for a provider call. */
|
|
141
|
+
type UsageInfo = z.infer<typeof UsageInfoSchema>;
|
|
142
|
+
/** Zod schema for results returned by `check()` and template helpers. */
|
|
143
|
+
declare const CheckResultSchema: z.ZodObject<{
|
|
144
|
+
pass: z.ZodBoolean;
|
|
145
|
+
reasoning: z.ZodString;
|
|
146
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
147
|
+
inputTokens: z.ZodNumber;
|
|
148
|
+
outputTokens: z.ZodNumber;
|
|
149
|
+
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
inputTokens: number;
|
|
153
|
+
outputTokens: number;
|
|
154
|
+
estimatedCost?: number | undefined;
|
|
155
|
+
durationSeconds?: number | undefined;
|
|
156
|
+
}, {
|
|
157
|
+
inputTokens: number;
|
|
158
|
+
outputTokens: number;
|
|
159
|
+
estimatedCost?: number | undefined;
|
|
160
|
+
durationSeconds?: number | undefined;
|
|
161
|
+
}>>;
|
|
162
|
+
} & {
|
|
163
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
164
|
+
priority: z.ZodEnum<["critical", "major", "minor"]>;
|
|
165
|
+
category: z.ZodEnum<["accessibility", "missing-element", "layout", "content", "styling", "functionality", "performance", "other"]>;
|
|
166
|
+
description: z.ZodString;
|
|
167
|
+
suggestion: z.ZodString;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
priority: "critical" | "major" | "minor";
|
|
170
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
171
|
+
description: string;
|
|
172
|
+
suggestion: string;
|
|
173
|
+
}, {
|
|
174
|
+
priority: "critical" | "major" | "minor";
|
|
175
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
176
|
+
description: string;
|
|
177
|
+
suggestion: string;
|
|
178
|
+
}>, "many">;
|
|
179
|
+
statements: z.ZodArray<z.ZodObject<{
|
|
180
|
+
statement: z.ZodString;
|
|
181
|
+
pass: z.ZodBoolean;
|
|
182
|
+
reasoning: z.ZodString;
|
|
183
|
+
confidence: z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
statement: string;
|
|
186
|
+
pass: boolean;
|
|
187
|
+
reasoning: string;
|
|
188
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
189
|
+
}, {
|
|
190
|
+
statement: string;
|
|
191
|
+
pass: boolean;
|
|
192
|
+
reasoning: string;
|
|
193
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
194
|
+
}>, "many">;
|
|
195
|
+
}, "strip", z.ZodTypeAny, {
|
|
196
|
+
issues: {
|
|
197
|
+
priority: "critical" | "major" | "minor";
|
|
198
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
199
|
+
description: string;
|
|
200
|
+
suggestion: string;
|
|
201
|
+
}[];
|
|
202
|
+
pass: boolean;
|
|
203
|
+
reasoning: string;
|
|
204
|
+
statements: {
|
|
205
|
+
statement: string;
|
|
206
|
+
pass: boolean;
|
|
207
|
+
reasoning: string;
|
|
208
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
209
|
+
}[];
|
|
210
|
+
usage?: {
|
|
211
|
+
inputTokens: number;
|
|
212
|
+
outputTokens: number;
|
|
213
|
+
estimatedCost?: number | undefined;
|
|
214
|
+
durationSeconds?: number | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
}, {
|
|
217
|
+
issues: {
|
|
218
|
+
priority: "critical" | "major" | "minor";
|
|
219
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
220
|
+
description: string;
|
|
221
|
+
suggestion: string;
|
|
222
|
+
}[];
|
|
223
|
+
pass: boolean;
|
|
224
|
+
reasoning: string;
|
|
225
|
+
statements: {
|
|
226
|
+
statement: string;
|
|
227
|
+
pass: boolean;
|
|
228
|
+
reasoning: string;
|
|
229
|
+
confidence?: "high" | "medium" | "low" | undefined;
|
|
230
|
+
}[];
|
|
231
|
+
usage?: {
|
|
232
|
+
inputTokens: number;
|
|
233
|
+
outputTokens: number;
|
|
234
|
+
estimatedCost?: number | undefined;
|
|
235
|
+
durationSeconds?: number | undefined;
|
|
236
|
+
} | undefined;
|
|
237
|
+
}>;
|
|
238
|
+
/** Result returned by `check()` and the template convenience methods. */
|
|
239
|
+
type CheckResult = z.infer<typeof CheckResultSchema>;
|
|
240
|
+
/** Zod schema for an individual visual change reported by `compare()`. */
|
|
241
|
+
declare const ChangeEntrySchema: z.ZodObject<{
|
|
242
|
+
description: z.ZodString;
|
|
243
|
+
severity: z.ZodEnum<["critical", "major", "minor"]>;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
description: string;
|
|
246
|
+
severity: "critical" | "major" | "minor";
|
|
247
|
+
}, {
|
|
248
|
+
description: string;
|
|
249
|
+
severity: "critical" | "major" | "minor";
|
|
250
|
+
}>;
|
|
251
|
+
/** Single visual change reported by `compare()`. */
|
|
252
|
+
type ChangeEntry = z.infer<typeof ChangeEntrySchema>;
|
|
253
|
+
/** Zod schema for the parsed model response returned by `compare()`. */
|
|
254
|
+
declare const CompareResultSchema: z.ZodObject<{
|
|
255
|
+
pass: z.ZodBoolean;
|
|
256
|
+
reasoning: z.ZodString;
|
|
257
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
258
|
+
inputTokens: z.ZodNumber;
|
|
259
|
+
outputTokens: z.ZodNumber;
|
|
260
|
+
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
261
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
inputTokens: number;
|
|
264
|
+
outputTokens: number;
|
|
265
|
+
estimatedCost?: number | undefined;
|
|
266
|
+
durationSeconds?: number | undefined;
|
|
267
|
+
}, {
|
|
268
|
+
inputTokens: number;
|
|
269
|
+
outputTokens: number;
|
|
270
|
+
estimatedCost?: number | undefined;
|
|
271
|
+
durationSeconds?: number | undefined;
|
|
272
|
+
}>>;
|
|
273
|
+
} & {
|
|
274
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
275
|
+
description: z.ZodString;
|
|
276
|
+
severity: z.ZodEnum<["critical", "major", "minor"]>;
|
|
277
|
+
}, "strip", z.ZodTypeAny, {
|
|
278
|
+
description: string;
|
|
279
|
+
severity: "critical" | "major" | "minor";
|
|
280
|
+
}, {
|
|
281
|
+
description: string;
|
|
282
|
+
severity: "critical" | "major" | "minor";
|
|
283
|
+
}>, "many">;
|
|
284
|
+
}, "strip", z.ZodTypeAny, {
|
|
285
|
+
pass: boolean;
|
|
286
|
+
reasoning: string;
|
|
287
|
+
changes: {
|
|
288
|
+
description: string;
|
|
289
|
+
severity: "critical" | "major" | "minor";
|
|
290
|
+
}[];
|
|
291
|
+
usage?: {
|
|
292
|
+
inputTokens: number;
|
|
293
|
+
outputTokens: number;
|
|
294
|
+
estimatedCost?: number | undefined;
|
|
295
|
+
durationSeconds?: number | undefined;
|
|
296
|
+
} | undefined;
|
|
297
|
+
}, {
|
|
298
|
+
pass: boolean;
|
|
299
|
+
reasoning: string;
|
|
300
|
+
changes: {
|
|
301
|
+
description: string;
|
|
302
|
+
severity: "critical" | "major" | "minor";
|
|
303
|
+
}[];
|
|
304
|
+
usage?: {
|
|
305
|
+
inputTokens: number;
|
|
306
|
+
outputTokens: number;
|
|
307
|
+
estimatedCost?: number | undefined;
|
|
308
|
+
durationSeconds?: number | undefined;
|
|
309
|
+
} | undefined;
|
|
310
|
+
}>;
|
|
311
|
+
/** Result returned by `compare()`, optionally including an AI-generated diff image. */
|
|
312
|
+
type CompareResult = z.infer<typeof CompareResultSchema> & {
|
|
313
|
+
diffImage?: DiffImageResult;
|
|
314
|
+
};
|
|
315
|
+
/** Zod schema for results returned by `ask()`. */
|
|
316
|
+
declare const AskResultSchema: z.ZodObject<{
|
|
317
|
+
summary: z.ZodString;
|
|
318
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
319
|
+
priority: z.ZodEnum<["critical", "major", "minor"]>;
|
|
320
|
+
category: z.ZodEnum<["accessibility", "missing-element", "layout", "content", "styling", "functionality", "performance", "other"]>;
|
|
321
|
+
description: z.ZodString;
|
|
322
|
+
suggestion: z.ZodString;
|
|
323
|
+
}, "strip", z.ZodTypeAny, {
|
|
324
|
+
priority: "critical" | "major" | "minor";
|
|
325
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
326
|
+
description: string;
|
|
327
|
+
suggestion: string;
|
|
328
|
+
}, {
|
|
329
|
+
priority: "critical" | "major" | "minor";
|
|
330
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
331
|
+
description: string;
|
|
332
|
+
suggestion: string;
|
|
333
|
+
}>, "many">;
|
|
334
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
335
|
+
inputTokens: z.ZodNumber;
|
|
336
|
+
outputTokens: z.ZodNumber;
|
|
337
|
+
estimatedCost: z.ZodOptional<z.ZodNumber>;
|
|
338
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
339
|
+
}, "strip", z.ZodTypeAny, {
|
|
340
|
+
inputTokens: number;
|
|
341
|
+
outputTokens: number;
|
|
342
|
+
estimatedCost?: number | undefined;
|
|
343
|
+
durationSeconds?: number | undefined;
|
|
344
|
+
}, {
|
|
345
|
+
inputTokens: number;
|
|
346
|
+
outputTokens: number;
|
|
347
|
+
estimatedCost?: number | undefined;
|
|
348
|
+
durationSeconds?: number | undefined;
|
|
349
|
+
}>>;
|
|
350
|
+
}, "strip", z.ZodTypeAny, {
|
|
351
|
+
issues: {
|
|
352
|
+
priority: "critical" | "major" | "minor";
|
|
353
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
354
|
+
description: string;
|
|
355
|
+
suggestion: string;
|
|
356
|
+
}[];
|
|
357
|
+
summary: string;
|
|
358
|
+
usage?: {
|
|
359
|
+
inputTokens: number;
|
|
360
|
+
outputTokens: number;
|
|
361
|
+
estimatedCost?: number | undefined;
|
|
362
|
+
durationSeconds?: number | undefined;
|
|
363
|
+
} | undefined;
|
|
364
|
+
}, {
|
|
365
|
+
issues: {
|
|
366
|
+
priority: "critical" | "major" | "minor";
|
|
367
|
+
category: "accessibility" | "missing-element" | "layout" | "content" | "styling" | "functionality" | "performance" | "other";
|
|
368
|
+
description: string;
|
|
369
|
+
suggestion: string;
|
|
370
|
+
}[];
|
|
371
|
+
summary: string;
|
|
372
|
+
usage?: {
|
|
373
|
+
inputTokens: number;
|
|
374
|
+
outputTokens: number;
|
|
375
|
+
estimatedCost?: number | undefined;
|
|
376
|
+
durationSeconds?: number | undefined;
|
|
377
|
+
} | undefined;
|
|
378
|
+
}>;
|
|
379
|
+
/** Result returned by `ask()`. */
|
|
380
|
+
type AskResult = z.infer<typeof AskResultSchema>;
|
|
381
|
+
/** Supported input shapes for image arguments accepted by the client. */
|
|
382
|
+
type ImageInput = Buffer | Uint8Array | string;
|
|
383
|
+
/** Supported image MIME types accepted by all providers. */
|
|
384
|
+
type SupportedMimeType = "image/jpeg" | "image/png" | "image/webp" | "image/gif";
|
|
385
|
+
/** Supported provider identifiers. */
|
|
386
|
+
type ProviderName = "anthropic" | "openai" | "google";
|
|
387
|
+
/** Optional reasoning depth requested from providers that support it. */
|
|
388
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh";
|
|
389
|
+
/**
|
|
390
|
+
* Configuration for creating a visual AI client.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* const client = visualAI({
|
|
395
|
+
* provider: "openai",
|
|
396
|
+
* model: "gpt-5-mini",
|
|
397
|
+
* apiKey: process.env.OPENAI_API_KEY,
|
|
398
|
+
* });
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
interface VisualAIConfig {
|
|
402
|
+
provider?: ProviderName;
|
|
403
|
+
apiKey?: string;
|
|
404
|
+
model?: string;
|
|
405
|
+
debug?: boolean;
|
|
406
|
+
maxTokens?: number;
|
|
407
|
+
reasoningEffort?: ReasoningEffort;
|
|
408
|
+
trackUsage?: boolean;
|
|
409
|
+
}
|
|
410
|
+
/** Optional instructions for `check()`. */
|
|
411
|
+
interface CheckOptions {
|
|
412
|
+
instructions?: readonly string[];
|
|
413
|
+
}
|
|
414
|
+
/** Optional instructions for `ask()`. */
|
|
415
|
+
interface AskOptions {
|
|
416
|
+
instructions?: readonly string[];
|
|
417
|
+
}
|
|
418
|
+
/** Metadata and binary content for an AI-generated diff image. */
|
|
419
|
+
interface DiffImageResult {
|
|
420
|
+
data: Buffer;
|
|
421
|
+
width: number;
|
|
422
|
+
height: number;
|
|
423
|
+
mimeType: "image/png";
|
|
424
|
+
}
|
|
425
|
+
/** Optional prompt, instructions, and diff configuration for `compare()`. */
|
|
426
|
+
interface CompareOptions {
|
|
427
|
+
prompt?: string;
|
|
428
|
+
instructions?: readonly string[];
|
|
429
|
+
diffImage?: boolean;
|
|
430
|
+
}
|
|
431
|
+
/** Optional instructions for `elementsVisible()` and `elementsHidden()`. */
|
|
432
|
+
interface ElementsVisibilityOptions {
|
|
433
|
+
instructions?: readonly string[];
|
|
434
|
+
}
|
|
435
|
+
/** Options for the built-in accessibility template. */
|
|
436
|
+
interface AccessibilityOptions {
|
|
437
|
+
checks?: AccessibilityCheckName[];
|
|
438
|
+
instructions?: readonly string[];
|
|
439
|
+
}
|
|
440
|
+
/** Options for the built-in layout template. */
|
|
441
|
+
interface LayoutOptions {
|
|
442
|
+
checks?: LayoutCheckName[];
|
|
443
|
+
instructions?: readonly string[];
|
|
444
|
+
}
|
|
445
|
+
/** Options for the built-in page-load template. */
|
|
446
|
+
interface PageLoadOptions {
|
|
447
|
+
expectLoaded?: boolean;
|
|
448
|
+
instructions?: readonly string[];
|
|
449
|
+
}
|
|
450
|
+
/** Options for the built-in content template. */
|
|
451
|
+
interface ContentOptions {
|
|
452
|
+
checks?: ContentCheckName[];
|
|
453
|
+
instructions?: readonly string[];
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* High-level client for running visual checks against screenshots or other images.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* const client = visualAI({ provider: "openai" });
|
|
462
|
+
* const result = await client.check("./tests/fixtures/small.png", "The button is visible");
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
interface VisualAIClient {
|
|
466
|
+
/**
|
|
467
|
+
* Verifies one or more statements against a single image.
|
|
468
|
+
*
|
|
469
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
470
|
+
* @param statements One or more statements to validate against the image.
|
|
471
|
+
* @param options Optional additional instructions appended to the prompt.
|
|
472
|
+
* @returns A structured result describing pass/fail, issues, and statement reasoning.
|
|
473
|
+
* @throws {VisualAIConfigError} When no statements are provided.
|
|
474
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
475
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
476
|
+
* @example
|
|
477
|
+
* ```ts
|
|
478
|
+
* const result = await client.check(screenshot, [
|
|
479
|
+
* "The primary CTA is visible",
|
|
480
|
+
* "There is no error banner",
|
|
481
|
+
* ]);
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
check(image: ImageInput, statements: string | string[], options?: CheckOptions): Promise<CheckResult>;
|
|
485
|
+
/**
|
|
486
|
+
* Asks an open-ended question about an image and returns a structured summary.
|
|
487
|
+
*
|
|
488
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
489
|
+
* @param prompt Prompt describing what to inspect in the image.
|
|
490
|
+
* @param options Optional additional instructions appended to the prompt.
|
|
491
|
+
* @returns A summary with any detected issues.
|
|
492
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
493
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
494
|
+
* @example
|
|
495
|
+
* ```ts
|
|
496
|
+
* const result = await client.ask(screenshot, "What looks visually broken on this page?");
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
ask(image: ImageInput, prompt: string, options?: AskOptions): Promise<AskResult>;
|
|
500
|
+
/**
|
|
501
|
+
* Compares two images and reports meaningful visual differences.
|
|
502
|
+
*
|
|
503
|
+
* @param imageA Baseline image source.
|
|
504
|
+
* @param imageB Candidate image source.
|
|
505
|
+
* @param options Optional comparison prompt, instructions, and diff-image settings.
|
|
506
|
+
* `gemini-3-flash-preview` generates an annotated diff image by default;
|
|
507
|
+
* pass `{ diffImage: false }` to opt out.
|
|
508
|
+
* @returns A structured comparison result with optional diff image metadata.
|
|
509
|
+
* @throws {VisualAIImageError} When either image cannot be loaded or decoded.
|
|
510
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
511
|
+
* @example
|
|
512
|
+
* ```ts
|
|
513
|
+
* const result = await client.compare(beforeScreenshot, afterScreenshot, {
|
|
514
|
+
* diffImage: true,
|
|
515
|
+
* });
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
compare(imageA: ImageInput, imageB: ImageInput, options?: CompareOptions): Promise<CompareResult>;
|
|
519
|
+
/**
|
|
520
|
+
* Checks that the listed elements are visible in an image.
|
|
521
|
+
*
|
|
522
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
523
|
+
* @param elements Element descriptions that should be present and visible.
|
|
524
|
+
* @param options Optional additional instructions appended to the prompt.
|
|
525
|
+
* @returns A structured pass/fail result for the requested elements.
|
|
526
|
+
* @throws {VisualAIConfigError} When `elements` is empty.
|
|
527
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
528
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
529
|
+
* @example
|
|
530
|
+
* ```ts
|
|
531
|
+
* await client.elementsVisible(screenshot, ["Save button", "Profile avatar"]);
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
elementsVisible(image: ImageInput, elements: string[], options?: ElementsVisibilityOptions): Promise<CheckResult>;
|
|
535
|
+
/**
|
|
536
|
+
* Checks that the listed elements are not visible in an image.
|
|
537
|
+
*
|
|
538
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
539
|
+
* @param elements Element descriptions that should be absent or hidden.
|
|
540
|
+
* @param options Optional additional instructions appended to the prompt.
|
|
541
|
+
* @returns A structured pass/fail result for the requested elements.
|
|
542
|
+
* @throws {VisualAIConfigError} When `elements` is empty.
|
|
543
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
544
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
545
|
+
* @example
|
|
546
|
+
* ```ts
|
|
547
|
+
* await client.elementsHidden(screenshot, ["Cookie banner"]);
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
elementsHidden(image: ImageInput, elements: string[], options?: ElementsVisibilityOptions): Promise<CheckResult>;
|
|
551
|
+
/**
|
|
552
|
+
* Runs the built-in accessibility template against an image.
|
|
553
|
+
*
|
|
554
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
555
|
+
* @param options Optional checks and extra instructions for the accessibility prompt.
|
|
556
|
+
* @returns A structured accessibility-focused check result.
|
|
557
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
558
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
559
|
+
* @example
|
|
560
|
+
* ```ts
|
|
561
|
+
* await client.accessibility(screenshot, { checks: ["contrast"] });
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
accessibility(image: ImageInput, options?: AccessibilityOptions): Promise<CheckResult>;
|
|
565
|
+
/**
|
|
566
|
+
* Runs the built-in layout template against an image.
|
|
567
|
+
*
|
|
568
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
569
|
+
* @param options Optional checks and extra instructions for the layout prompt.
|
|
570
|
+
* @returns A structured layout-focused check result.
|
|
571
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
572
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts
|
|
575
|
+
* await client.layout(screenshot, { checks: ["overflow", "alignment"] });
|
|
576
|
+
* ```
|
|
577
|
+
*/
|
|
578
|
+
layout(image: ImageInput, options?: LayoutOptions): Promise<CheckResult>;
|
|
579
|
+
/**
|
|
580
|
+
* Runs the built-in page-load template against an image.
|
|
581
|
+
*
|
|
582
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
583
|
+
* @param options Optional page-load expectations and extra instructions.
|
|
584
|
+
* @returns A structured page-load check result.
|
|
585
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
586
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
587
|
+
* @example
|
|
588
|
+
* ```ts
|
|
589
|
+
* await client.pageLoad(screenshot, { expectLoaded: true });
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
pageLoad(image: ImageInput, options?: PageLoadOptions): Promise<CheckResult>;
|
|
593
|
+
/**
|
|
594
|
+
* Runs the built-in content template against an image.
|
|
595
|
+
*
|
|
596
|
+
* @param image Image source as a buffer, URL, file path, or base64 string.
|
|
597
|
+
* @param options Optional content checks and extra instructions.
|
|
598
|
+
* @returns A structured content-focused check result.
|
|
599
|
+
* @throws {VisualAIImageError} When the image cannot be loaded or decoded.
|
|
600
|
+
* @throws {VisualAIError} When the provider rejects the request or returns invalid output.
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* await client.content(screenshot, { checks: ["placeholder-text"] });
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
content(image: ImageInput, options?: ContentOptions): Promise<CheckResult>;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Creates a configured visual AI client.
|
|
610
|
+
*
|
|
611
|
+
* @param config Provider selection and runtime options for subsequent requests.
|
|
612
|
+
* @returns A `VisualAIClient` instance with check, compare, ask, and template helpers.
|
|
613
|
+
* @throws {VisualAIConfigError} When the provider or model configuration is invalid.
|
|
614
|
+
* @throws {VisualAIAuthError} When required API credentials are missing.
|
|
615
|
+
* @example
|
|
616
|
+
* ```ts
|
|
617
|
+
* import { expect, test } from "@playwright/test";
|
|
618
|
+
* import { visualAI } from "visual-ai-assertions";
|
|
619
|
+
*
|
|
620
|
+
* test("hero loads correctly", async ({ page }) => {
|
|
621
|
+
* const client = visualAI({
|
|
622
|
+
* provider: "openai",
|
|
623
|
+
* apiKey: process.env.OPENAI_API_KEY,
|
|
624
|
+
* });
|
|
625
|
+
*
|
|
626
|
+
* await page.goto("https://example.com");
|
|
627
|
+
* const screenshot = await page.screenshot();
|
|
628
|
+
* const result = await client.check(screenshot, [
|
|
629
|
+
* "The hero heading is visible",
|
|
630
|
+
* "There is no loading spinner",
|
|
631
|
+
* ]);
|
|
632
|
+
*
|
|
633
|
+
* expect(result.pass).toBe(true);
|
|
634
|
+
* });
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
declare function visualAI(config?: VisualAIConfig): VisualAIClient;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Discrete error codes exposed by visual-ai-assertions for programmatic handling.
|
|
641
|
+
*/
|
|
642
|
+
type VisualAIErrorCode = "VISUAL_AI_ERROR" | "AUTH_FAILED" | "RATE_LIMITED" | "PROVIDER_ERROR" | "IMAGE_INVALID" | "RESPONSE_PARSE_FAILED" | "CONFIG_INVALID" | "ASSERTION_FAILED";
|
|
643
|
+
/**
|
|
644
|
+
* Base class for all library errors.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```ts
|
|
648
|
+
* try {
|
|
649
|
+
* // ...
|
|
650
|
+
* } catch (error) {
|
|
651
|
+
* if (error instanceof VisualAIError) {
|
|
652
|
+
* console.error(error.code, error.message);
|
|
653
|
+
* }
|
|
654
|
+
* }
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
declare class VisualAIError<TCode extends VisualAIErrorCode = VisualAIErrorCode> extends Error {
|
|
658
|
+
readonly code: TCode;
|
|
659
|
+
constructor(message: string, code?: TCode);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Thrown when a provider rejects the configured API credentials.
|
|
663
|
+
*
|
|
664
|
+
* @example
|
|
665
|
+
* ```ts
|
|
666
|
+
* throw new VisualAIAuthError("Anthropic API key not found");
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
declare class VisualAIAuthError extends VisualAIError<"AUTH_FAILED"> {
|
|
670
|
+
readonly code: "AUTH_FAILED";
|
|
671
|
+
constructor(message: string);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Thrown when a provider enforces a rate limit.
|
|
675
|
+
*
|
|
676
|
+
* Carries `retryAfter` when the provider includes retry guidance.
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* throw new VisualAIRateLimitError("Rate limited", 30);
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
declare class VisualAIRateLimitError extends VisualAIError<"RATE_LIMITED"> {
|
|
684
|
+
readonly code: "RATE_LIMITED";
|
|
685
|
+
retryAfter?: number;
|
|
686
|
+
constructor(message: string, retryAfter?: number);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Thrown when a provider returns an unexpected non-auth, non-rate-limit failure.
|
|
690
|
+
*
|
|
691
|
+
* Carries `statusCode` when the provider exposes an HTTP status.
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* ```ts
|
|
695
|
+
* throw new VisualAIProviderError("Provider returned 500", 500);
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
declare class VisualAIProviderError extends VisualAIError<"PROVIDER_ERROR"> {
|
|
699
|
+
readonly code: "PROVIDER_ERROR";
|
|
700
|
+
statusCode?: number;
|
|
701
|
+
constructor(message: string, statusCode?: number);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Thrown when an image input cannot be loaded, decoded, or validated.
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```ts
|
|
708
|
+
* throw new VisualAIImageError("Unsupported image format: image/bmp");
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
declare class VisualAIImageError extends VisualAIError<"IMAGE_INVALID"> {
|
|
712
|
+
readonly code: "IMAGE_INVALID";
|
|
713
|
+
constructor(message: string);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Thrown when a provider response cannot be parsed into the library result schema.
|
|
717
|
+
*
|
|
718
|
+
* Carries `rawResponse` so callers can inspect the original model output.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* throw new VisualAIResponseParseError("Invalid JSON", rawText);
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
declare class VisualAIResponseParseError extends VisualAIError<"RESPONSE_PARSE_FAILED"> {
|
|
726
|
+
readonly code: "RESPONSE_PARSE_FAILED";
|
|
727
|
+
rawResponse: string;
|
|
728
|
+
constructor(message: string, rawResponse: string);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Thrown when library configuration is missing or invalid.
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```ts
|
|
735
|
+
* throw new VisualAIConfigError("At least one statement is required for check()");
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
declare class VisualAIConfigError extends VisualAIError<"CONFIG_INVALID"> {
|
|
739
|
+
readonly code: "CONFIG_INVALID";
|
|
740
|
+
constructor(message: string);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Thrown by assertion helpers when a visual check or comparison fails.
|
|
744
|
+
*
|
|
745
|
+
* Carries the failed `result` for further inspection.
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```ts
|
|
749
|
+
* throw new VisualAIAssertionError("Visual assertion failed", result);
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
declare class VisualAIAssertionError extends VisualAIError<"ASSERTION_FAILED"> {
|
|
753
|
+
readonly code: "ASSERTION_FAILED";
|
|
754
|
+
result: CheckResult | CompareResult;
|
|
755
|
+
constructor(message: string, result: CheckResult | CompareResult);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Union of all concrete error subclasses exposed by the library.
|
|
759
|
+
*/
|
|
760
|
+
type VisualAIKnownError = VisualAIAuthError | VisualAIRateLimitError | VisualAIProviderError | VisualAIImageError | VisualAIResponseParseError | VisualAIConfigError | VisualAIAssertionError;
|
|
761
|
+
/**
|
|
762
|
+
* Narrows an unknown thrown value to the concrete visual-ai-assertions error union.
|
|
763
|
+
*
|
|
764
|
+
* Use this helper when you want `switch (error.code)` to narrow to subclass-specific fields.
|
|
765
|
+
*
|
|
766
|
+
* @param error Unknown thrown value.
|
|
767
|
+
* @returns `true` when the value is one of the concrete library error subclasses.
|
|
768
|
+
* @example
|
|
769
|
+
* ```ts
|
|
770
|
+
* try {
|
|
771
|
+
* // ...
|
|
772
|
+
* } catch (error) {
|
|
773
|
+
* if (isVisualAIKnownError(error)) {
|
|
774
|
+
* switch (error.code) {
|
|
775
|
+
* case "RATE_LIMITED":
|
|
776
|
+
* console.error(error.retryAfter);
|
|
777
|
+
* break;
|
|
778
|
+
* case "PROVIDER_ERROR":
|
|
779
|
+
* console.error(error.statusCode);
|
|
780
|
+
* break;
|
|
781
|
+
* }
|
|
782
|
+
* }
|
|
783
|
+
* }
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
declare function isVisualAIKnownError(error: unknown): error is VisualAIKnownError;
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Formats a check result into a readable multiline string for logs or test failures.
|
|
790
|
+
*
|
|
791
|
+
* @param result Structured result returned by `check()` or a template helper.
|
|
792
|
+
* @param label Optional label appended to the output header.
|
|
793
|
+
* @returns A human-readable summary of the check result.
|
|
794
|
+
* @example
|
|
795
|
+
* ```ts
|
|
796
|
+
* console.log(formatCheckResult(result, "Checkout page"));
|
|
797
|
+
* ```
|
|
798
|
+
*/
|
|
799
|
+
declare function formatCheckResult(result: CheckResult, label?: string): string;
|
|
800
|
+
/**
|
|
801
|
+
* Formats a compare result into a readable multiline string for logs or test failures.
|
|
802
|
+
*
|
|
803
|
+
* @param result Structured result returned by `compare()`.
|
|
804
|
+
* @param label Optional label appended to the output header.
|
|
805
|
+
* @returns A human-readable summary of the compare result.
|
|
806
|
+
* @example
|
|
807
|
+
* ```ts
|
|
808
|
+
* console.log(formatCompareResult(result, "Before/after deploy"));
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
811
|
+
declare function formatCompareResult(result: CompareResult, label?: string): string;
|
|
812
|
+
/**
|
|
813
|
+
* Throws a `VisualAIAssertionError` when a check result did not pass.
|
|
814
|
+
*
|
|
815
|
+
* @param result Structured result returned by `check()` or a template helper.
|
|
816
|
+
* @param label Optional label appended to the assertion message.
|
|
817
|
+
* @returns Nothing when the result passes.
|
|
818
|
+
* @throws {VisualAIAssertionError} When `result.pass` is `false`.
|
|
819
|
+
* @example
|
|
820
|
+
* ```ts
|
|
821
|
+
* assertVisualResult(result, "Homepage");
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
declare function assertVisualResult(result: CheckResult, label?: string): void;
|
|
825
|
+
/**
|
|
826
|
+
* Throws a `VisualAIAssertionError` when a compare result did not pass.
|
|
827
|
+
*
|
|
828
|
+
* @param result Structured result returned by `compare()`.
|
|
829
|
+
* @param label Optional label appended to the assertion message.
|
|
830
|
+
* @returns Nothing when the result passes.
|
|
831
|
+
* @throws {VisualAIAssertionError} When `result.pass` is `false`.
|
|
832
|
+
* @example
|
|
833
|
+
* ```ts
|
|
834
|
+
* assertVisualCompareResult(result, "Login flow");
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
837
|
+
declare function assertVisualCompareResult(result: CompareResult, label?: string): void;
|
|
838
|
+
|
|
839
|
+
export { Accessibility, type AccessibilityCheckName, type AccessibilityOptions, type AskOptions, type AskResult, AskResultSchema, type ChangeEntry, ChangeEntrySchema, type CheckOptions, type CheckResult, CheckResultSchema, type CompareOptions, type CompareResult, CompareResultSchema, type Confidence, ConfidenceSchema, Content, type ContentCheckName, type ContentOptions, DEFAULT_MODELS, type DiffImageResult, type ElementsVisibilityOptions, type ImageInput, type Issue, type IssueCategory, IssueCategorySchema, type IssuePriority, IssuePrioritySchema, IssueSchema, type KnownModelName, Layout, type LayoutCheckName, type LayoutOptions, Model, type PageLoadOptions, Provider, type ProviderName, type ReasoningEffort, type StatementResult, StatementResultSchema, type SupportedMimeType, type UsageInfo, UsageInfoSchema, VALID_PROVIDERS, VisualAIAssertionError, VisualAIAuthError, type VisualAIClient, type VisualAIConfig, VisualAIConfigError, VisualAIError, type VisualAIErrorCode, VisualAIImageError, type VisualAIKnownError, VisualAIProviderError, VisualAIRateLimitError, VisualAIResponseParseError, assertVisualCompareResult, assertVisualResult, formatCheckResult, formatCompareResult, isVisualAIKnownError, visualAI };
|