-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.d.ts
274 lines (227 loc) · 6.57 KB
/
index.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
import type { TestInfo } from "@playwright/test"
import type {
CoverageReportOptions,
ReportDescription,
V8CoverageEntry,
Watermarks,
CoverageResults,
CoverageSummary,
MetricsSummary,
CoverageFile,
CoverageRange,
AddedResults
} from "monocart-coverage-reports";
export type {
TestInfo,
CoverageReportOptions,
ReportDescription,
V8CoverageEntry,
Watermarks,
CoverageResults,
CoverageSummary,
MetricsSummary,
CoverageFile,
CoverageRange,
AddedResults
}
export interface Helper {
find: (callback: ((item: any, parent: any) => void)) => any;
filter: (callback: ((item: any, parent: any) => void)) => any[];
/** Traverse all cases, suites, and steps. */
forEach: (callback: ((item: any, parent: any) => void | "break")) => void;
/** send email with nodemailer: https://nodemailer.com/ */
sendEmail: (emailOptions: {
/** email transport: https://nodemailer.com/smtp/ */
transport: any;
/** email message: https://nodemailer.com/message/ */
message: any;
}) => Promise<void>;
}
export type MonocartReporterOptions = {
/** logging levels: off, error, info, debug */
logging?: string;
/** the report name */
name?: string;
/**
* image url, supports data url:
* `data:image/png;base64,${fs.readFileSync('path-to/your-logo.png').toString('base64')}`
*/
logo?: string;
/** the output file path (relative process.cwd) */
outputFile?: string;
/** output json file for data only */
json?: boolean;
/** output zip file for all report files
* {boolean} using default path
* {string} zip file path
*/
zip?: boolean | string | {
/** the zip file path */
outputFile?: string;
/** whether to clean the files after zipped */
clean?: boolean;
};
/**
* whether to copy attachments to the reporter output dir, defaults to true
* it is useful when there are multiple html reports being output
*/
copyAttachments?: boolean;
/** attachment path handler, for example:
* ```js
* attachmentPath: (currentPath, extras) => `https://cenfun.github.io/monocart-reporter/${currentPath}`
* ```
*/
attachmentPath?: (currentPath: string, extras: any) => string;
/** custom trace viewer url: https://github.com/cenfun/monocart-reporter?#view-trace-online */
traceViewerUrl?: string;
/** timezone offset in minutes, For example: GMT+0800 = -480 */
timezoneOffset?: number;
/** normal or exclude-idle */
durationStrategy?: 'normal' | 'exclude-idle',
/** global coverage options: https://github.com/cenfun/monocart-reporter?#code-coverage-report
* ```js
* coverage: {
* entryFilter: (entry) => true,
* sourceFilter: (sourcePath) => sourcePath.search(/src\/.+/) !== -1,
* }
* ```
*/
coverage?: CoverageReportOptions;
/** Global State Management: https://github.com/cenfun/monocart-reporter?#global-state-management */
state?: {
data?: any;
server?: {
host?: string;
port?: number;
}
onReceive?: (...args: any[]) => any;
onClose?: (data: any, config: any) => void;
},
/** trend data handler: https://github.com/cenfun/monocart-reporter?#trend-chart
* ```js
* trend: () => './monocart-report/index.json'
* ```
*/
trend?: string | (() => Promise<string | any>);
/** custom tags style: https://github.com/cenfun/monocart-reporter?#style-tags
* ```js
* tags: {
* smoke: {
* 'background': '#6F9913'
* },
* sanity: {
* 'background': '#178F43'
* }
* }
* ```
*/
tags?: {
[key: string]: any;
};
/** columns data handler: https://github.com/cenfun/monocart-reporter?#style-tags */
columns?: (defaultColumns: any[]) => void;
/** rows data handler (suite, case and step) https://github.com/cenfun/monocart-reporter?#custom-data-visitor */
visitor?: (data: any, metadata: any) => void;
/** enable/disable custom fields in comments. Defaults to true. */
customFieldsInComments?: boolean;
/** mermaid options */
mermaid?: {
/** mermaid script url, for example: https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js */
scriptSrc?: string;
/** mermaid config: https://mermaid.js.org/config/schema-docs/config.html */
config?: any;
}
/** enable/disable group or levels */
groupOptions?: {
group?: boolean;
shard?: boolean;
project?: boolean;
file?: boolean;
describe?: boolean;
step?: boolean;
merge?: boolean;
}
/**
* onData hook
*/
onData?: (reportData: any, rawData: any) => Promise<void>;
/** onEnd hook: https://github.com/cenfun/monocart-reporter?#onend-hook */
onEnd?: (reportData: any, helper: Helper) => Promise<void>;
}
/**
* merge
*/
export function merge(
reportDataList: any[],
options?: MonocartReporterOptions
): Promise<void>;
/**
* audit
*/
export type AuditReportOptions = {
title?: string;
outputDir?: string;
outputName?: string;
};
export function attachAuditReport(
runnerResult: any,
testInfo: TestInfo,
options?: AuditReportOptions
): Promise<any>;
/**
* coverage
*/
export function addCoverageReport(
coverageData: any[] | any,
testInfo: TestInfo
): Promise<AddedResults>;
export function attachCoverageReport(
coverageData: any[] | any,
testInfo: TestInfo,
options?: CoverageReportOptions
): Promise<CoverageResults>;
/**
* network
*/
export type NetworkReportOptions = {
title?: string;
outputDir?: string;
outputName?: string;
// Whether inline all scripts to the single HTML file.
inline?: boolean;
};
export function attachNetworkReport(
har: string | Buffer,
testInfo: TestInfo,
options?: NetworkReportOptions
): Promise<any>;
export function setMetadata(
data: {
[key: string]: any;
},
testInfo: TestInfo
): void;
/**
* state
*/
export type StateOptions = {
host?: string;
port?: number;
timeout?: number;
};
export type State = {
get: {
(key: string): Promise<any>,
(...args: string[]): Promise<any[]>
},
set: {
(key: string, value: any): Promise<void>,
(obj: any): Promise<void>
},
remove: {
(key: string): Promise<void>,
(...args: string[]): Promise<void>
},
send: (...args: any[]) => Promise<any>
}
export function useState(options?: StateOptions): State;