-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcommands.d.ts
164 lines (141 loc) · 3.63 KB
/
commands.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/// <reference types="cypress" />
declare namespace Cypress {
interface WebVitalsThresholds {
/**
* Largest contentful paint.
* @see https://web.dev/lcp/
*/
lcp?: number;
/**
* First input delay.
* @see https://web.dev/fid/
*/
fid?: number;
/**
* Cumulative layout shift.
* @see https://web.dev/cls/
*/
cls?: number;
/**
* First contentful paint.
* @see https://web.dev/fcp/
*/
fcp?: number;
/**
* Time to first byte.
* @see https://web.dev/time-to-first-byte/
*/
ttfb?: number;
/**
* Interaction to next paint.
* @see https://web.dev/inp/
*/
inp?: number | null;
}
interface WebVitalsResults {
/**
* Largest contentful paint.
* @see https://web.dev/lcp/
*/
lcp: number | null;
/**
* First input delay.
* @see https://web.dev/fid/
*/
fid: number | null;
/**
* Cumulative layout shift.
* @see https://web.dev/cls/
*/
cls: number | null;
/**
* First contentful paint.
* @see https://web.dev/fcp/
*/
fcp: number | null;
/**
* Time to first byte.
* @see https://web.dev/time-to-first-byte/
*/
ttfb: number | null;
/**
* Interaction to next paint.
* @see https://web.dev/inp/
*/
inp: number | null;
}
interface WebVitalsReport {
strict: boolean;
thresholds: WebVitalsThresholds;
results: WebVitalsResults;
}
interface StartWebVitalsCaptureConfig {
/**
* Url of page for auditing Web Vitals. If not provided will
* attempt to discover the current url using `cy.url()`.
*/
url?: string;
/**
* Additional parameters to pass to internal cy.visit() command when visit
* the url.
*/
[visitKey: string]: unknown;
}
interface ReportWebVitalsConfig {
/**
* Callback for custom handling of the report results, e.g. for
* sending results to application monitoring platforms.
*/
onReport?: (report: WebVitalsReport) => void;
/**
* Enables strict mode in which tests will fail if metrics with
* specified thresholds cannot be calculated.
* @default false
*/
strict?: boolean;
/**
* Thresholds to compare against captured Web Vitals metrics.
*/
thresholds?: WebVitalsThresholds;
/**
* Time in ms to wait for Web Vitals to be reported before failing.
* @default 10000
*/
vitalsReportedTimeout?: number;
}
interface WebVitalsConfig
extends StartWebVitalsCaptureConfig,
ReportWebVitalsConfig {
/**
* Selector(s) used for capturing FID. The first matching element is
* used for each provided selector.
* @default "body"
*/
firstInputSelector?: string | string[];
}
interface Chainable<Subject> {
/**
* Runs a Web Vitals audit
* @example
* cy.vitals({ thresholds, url, selector });
* @param {WebVitalsConfig} [webVitalsConfig] configuration
*/
vitals(webVitalsConfig?: WebVitalsConfig);
/**
* Starts a Web Vitals audit. Use with `cy.reportVitals()`.
* @example
* cy.startVitalsCapture({ url });
* @param {StartWebVitalsCaptureConfig} [startWebVitalsCaptureConfig] configuration
*/
startVitalsCapture(
startWebVitalsCaptureConfig?: StartWebVitalsCaptureConfig
);
/**
* Reports on a Web Vitals audit. Use with `cy.startVitalsCapture()`.
* @example
* cy.reportVitals({ thresholds });
* @param {ReportWebVitalsConfig} [reportWebVitalsConfig] configuration
*/
reportVitals(reportWebVitalsConfig?: ReportWebVitalsConfig);
}
}