@testomatio/reporter 2.3.9-beta-bin-fix → 2.4.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.
Files changed (62) hide show
  1. package/README.md +3 -2
  2. package/lib/adapter/codecept.js +12 -9
  3. package/lib/bin/cli.js +40 -11
  4. package/lib/bin/reportXml.js +5 -2
  5. package/lib/client.d.ts +1 -11
  6. package/lib/client.js +57 -152
  7. package/lib/data-storage.d.ts +1 -1
  8. package/lib/helpers.d.ts +1 -0
  9. package/lib/helpers.js +4 -0
  10. package/lib/junit-adapter/csharp.d.ts +0 -1
  11. package/lib/junit-adapter/csharp.js +43 -7
  12. package/lib/junit-adapter/nunit-parser.d.ts +82 -0
  13. package/lib/junit-adapter/nunit-parser.js +433 -0
  14. package/lib/pipe/bitbucket.js +5 -5
  15. package/lib/pipe/coverage.d.ts +82 -0
  16. package/lib/pipe/coverage.js +373 -0
  17. package/lib/pipe/gitlab.js +4 -4
  18. package/lib/pipe/index.js +2 -0
  19. package/lib/pipe/testomatio.d.ts +3 -2
  20. package/lib/pipe/testomatio.js +44 -18
  21. package/lib/reporter-functions.js +14 -12
  22. package/lib/reporter.d.ts +31 -21
  23. package/lib/reporter.js +40 -5
  24. package/lib/services/artifacts.d.ts +1 -1
  25. package/lib/services/key-values.d.ts +1 -1
  26. package/lib/services/links.d.ts +1 -1
  27. package/lib/services/logger.d.ts +1 -1
  28. package/lib/uploader.js +4 -0
  29. package/lib/utils/log-formatter.d.ts +28 -0
  30. package/lib/utils/log-formatter.js +127 -0
  31. package/lib/utils/pipe_utils.d.ts +15 -0
  32. package/lib/utils/pipe_utils.js +44 -2
  33. package/lib/utils/utils.d.ts +6 -0
  34. package/lib/utils/utils.js +260 -25
  35. package/lib/xmlReader.d.ts +32 -26
  36. package/lib/xmlReader.js +121 -52
  37. package/package.json +12 -7
  38. package/src/adapter/codecept.js +19 -19
  39. package/src/adapter/mocha.js +1 -1
  40. package/src/adapter/playwright.js +2 -2
  41. package/src/bin/cli.js +51 -13
  42. package/src/bin/reportXml.js +5 -2
  43. package/src/client.js +69 -130
  44. package/src/helpers.js +1 -0
  45. package/src/junit-adapter/csharp.js +48 -6
  46. package/src/junit-adapter/nunit-parser.js +474 -0
  47. package/src/pipe/bitbucket.js +5 -5
  48. package/src/pipe/coverage.js +440 -0
  49. package/src/pipe/debug.js +1 -2
  50. package/src/pipe/gitlab.js +4 -4
  51. package/src/pipe/index.js +2 -0
  52. package/src/pipe/testomatio.js +109 -85
  53. package/src/reporter-functions.js +15 -12
  54. package/src/reporter.js +6 -4
  55. package/src/services/links.js +1 -1
  56. package/src/uploader.js +5 -0
  57. package/src/utils/log-formatter.js +113 -0
  58. package/src/utils/pipe_utils.js +52 -3
  59. package/src/utils/utils.js +277 -22
  60. package/src/xmlReader.js +144 -46
  61. package/types/types.d.ts +364 -0
  62. package/types/vitest.types.d.ts +93 -0
@@ -0,0 +1,364 @@
1
+ declare module '@testomatio/reporter' {
2
+ /**
3
+ * Stores path to file as artifact and uploads it to the S3 storage
4
+ * @param data - path to file or object with path, type and name
5
+ * @param context - optional context parameter
6
+ */
7
+ export function artifact(data: string | ArtifactData, context?: any): void;
8
+
9
+ /**
10
+ * Attach log message(s) to the test report
11
+ * @param args - log messages
12
+ */
13
+ export function log(...args: any[]): void;
14
+
15
+ /**
16
+ * Similar to "log" function but marks message in report as a step
17
+ * @param message - step message
18
+ */
19
+ export function step(message: string): void;
20
+
21
+ /**
22
+ * Add key-value pair(s) to the test report
23
+ * @param keyValue - object { key: value } (multiple props allowed) or key (string)
24
+ * @param value - optional value when keyValue is a string
25
+ */
26
+ export function meta(keyValue: Record<string, string> | string, value?: string | null): void;
27
+
28
+ /**
29
+ * Add a single label to the test report
30
+ * @param key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
31
+ * @param value - optional label value (e.g. 'high', 'login')
32
+ */
33
+ export function label(key: string, value?: string | null): void;
34
+
35
+ /**
36
+ * Add link(s) to the test report
37
+ * @param testIds - test IDs to link
38
+ */
39
+ export function linkTest(...testIds: string[]): void;
40
+
41
+ /**
42
+ * Add JIRA issue link(s) to the test report
43
+ * @param jiraIds - JIRA issue IDs to link
44
+ */
45
+ export function linkJira(...jiraIds: string[]): void;
46
+
47
+ /**
48
+ * Logger service for intercepting and managing logs
49
+ */
50
+ export const logger: Logger;
51
+
52
+ interface ArtifactData {
53
+ path: string;
54
+ type: string;
55
+ name: string;
56
+ }
57
+
58
+ interface Logger {
59
+ logLevel: string;
60
+ prettyObjects: boolean;
61
+
62
+ /**
63
+ * Define a step inside a test. Step name is attached to the report
64
+ * @param strings - template literal strings
65
+ * @param values - template literal values
66
+ */
67
+ step(strings: any, ...values: any[]): void;
68
+
69
+ /**
70
+ * Get logs for a specific context
71
+ * @param context - testId or test context from test runner
72
+ */
73
+ getLogs(context: string): string[];
74
+
75
+ /**
76
+ * Template literal log function
77
+ * @param strings - template literal strings or message
78
+ * @param args - arguments
79
+ */
80
+ _templateLiteralLog(strings: any, ...args: any[]): void;
81
+
82
+ // Console methods
83
+ assert(...args: any[]): void;
84
+ debug(...args: any[]): void;
85
+ error(...args: any[]): void;
86
+ info(...args: any[]): void;
87
+ log(...args: any[]): void;
88
+ trace(...args: any[]): void;
89
+ warn(...args: any[]): void;
90
+
91
+ /**
92
+ * Intercept user logger messages
93
+ * @param userLogger - user's logger instance
94
+ */
95
+ intercept(userLogger: any): void;
96
+
97
+ /**
98
+ * Stop logger interception
99
+ */
100
+ stopInterception(): void;
101
+
102
+ /**
103
+ * Configure logger settings
104
+ * @param config - configuration options
105
+ */
106
+ configure(config?: LoggerConfig): void;
107
+ }
108
+
109
+ interface LoggerConfig {
110
+ logLevel?: string;
111
+ prettyObjects?: boolean;
112
+ }
113
+
114
+ const _default: {
115
+ /**
116
+ * @deprecated Use `log` or `testomat.log`
117
+ */
118
+ testomatioLogger: Logger;
119
+ artifact: typeof artifact;
120
+ log: typeof log;
121
+ logger: Logger;
122
+ meta: typeof meta;
123
+ step: typeof step;
124
+ label: typeof label;
125
+ linkTest: typeof linkTest;
126
+ linkJira: typeof linkJira;
127
+ };
128
+
129
+ export default _default;
130
+ }
131
+
132
+ export interface FileType {
133
+ path: string;
134
+ type: string;
135
+ title?: string;
136
+ testId?: string;
137
+ }
138
+
139
+ /**
140
+ * Object representing a unit test result that can be sent to a reporting service.
141
+ */
142
+ export interface TestData {
143
+ /** Unique ID of test report data to send to multiple times. */
144
+ rid?: string;
145
+
146
+ /** The title of the test case being reported. */
147
+ title?: string;
148
+
149
+ /** The title of the test suite to which the test case belongs. Required when creating a new test suite inside Testomat.io. */
150
+ suite_title?: string;
151
+
152
+ /** file in which test is located */
153
+ file?: string;
154
+
155
+ /** The unique identifier from Testomat.io of the test suite to which the test case belongs. */
156
+ suite_id?: string;
157
+
158
+ /** The unique identifier from Testomat.io of the test case. If provided, updates the existing test case with the given ID. */
159
+ test_id?: string;
160
+
161
+ /** An object representing an error that occurred during the execution of the test case. */
162
+ error?: Error;
163
+
164
+ /** The time it took to execute the test case, in milliseconds. */
165
+ time?: number;
166
+
167
+ /** Timestamp when the test was reported, in microseconds since Unix epoch. */
168
+ timestamp?: number;
169
+
170
+ /** Additional data associated with the test case. Used for parametrized tests. */
171
+ example?: any;
172
+
173
+ /** An array of file paths or objects representing files associated with the test case. */
174
+ files?: (string | FileType)[];
175
+
176
+ /** An array of `Buffer` objects representing files associated with the test case. */
177
+ filesBuffers?: Buffer[];
178
+
179
+ /** The steps taken or logs printed during the execution of the test case. */
180
+ steps?: Step[] | string;
181
+
182
+ /** The stack taken or logs printed during the execution of the test case. */
183
+ stack?: string;
184
+
185
+ tags?: string[];
186
+
187
+ /** The current source code of a test. Used only for JUnit or Newman reports, when we create tests from a run */
188
+ code?: string;
189
+
190
+ /** A one-line result message, usually error.message. */
191
+ message?: string;
192
+
193
+ /** Logs catched by logger */
194
+ logs?: string;
195
+
196
+ /** Manually attached artifacts */
197
+ manuallyAttachedArtifacts?: (string | { path: string; type: string })[];
198
+
199
+ /** Meta information (key: value) */
200
+ meta?: { [key: string]: any } | {};
201
+
202
+ /** Links array (e.g. [{test: 'TEST-123'}, {label: 'smoke'}]) */
203
+ links?: object[];
204
+
205
+ /** Whether to overwrite status of this test to avoid saving as retry (defaults to false) */
206
+ overwrite?: boolean;
207
+ }
208
+
209
+ /**
210
+ * Object representing a result of a Run.
211
+ */
212
+ export interface RunData {
213
+ /** The status of the test run. */
214
+ status: RunStatus;
215
+
216
+ /** is this run a part of parallel run */
217
+ parallel: boolean;
218
+
219
+ /** mark tests not included in report as detached */
220
+ detach: boolean;
221
+
222
+ /** A boolean indicating whether new test cases should be created in Testomat.io when submitting the test run. */
223
+ create_tests?: boolean;
224
+
225
+ /** The total number of test cases in the test run. Used in JUnit report. */
226
+ tests_count?: number;
227
+
228
+ /** The number of test cases that passed in the test run. Used in JUnit report. */
229
+ passed_count?: number;
230
+
231
+ /** The number of test cases that failed in the test run. Used in JUnit report. */
232
+ failed_count?: number;
233
+
234
+ /** The number of test cases that were skipped in the test run. */
235
+ skipped_count?: number;
236
+
237
+ /** If duration is pre-set value as in XML tests set it */
238
+ duration?: number;
239
+
240
+ /**
241
+ * An array of `TestData` objects representing the individual test cases in the test run.
242
+ * Used for JUNit report when we don't send the tests in realtime but in a batch as a part of final result */
243
+ tests?: TestData[];
244
+ }
245
+
246
+ export enum TestStatus {
247
+ Passed = 'passed',
248
+ Failed = 'failed',
249
+ Skipped = 'skipped',
250
+ }
251
+
252
+ export enum RunStatus {
253
+ Passed = 'passed',
254
+ Failed = 'failed',
255
+ Finished = 'finished',
256
+ }
257
+
258
+ export interface Pipe {
259
+ isEnabled: boolean;
260
+ store: {};
261
+
262
+ /** starts run */
263
+ createRun(): Promise<void>;
264
+
265
+ /** adds a test to the current run */
266
+ addTest(test: TestData): any;
267
+
268
+ /** ends the run */
269
+ finishRun(runParams: RunData): Promise<void>;
270
+
271
+ /** name of this pipe */
272
+ toString(): string;
273
+ }
274
+
275
+ export interface PipeResult {
276
+ /** Name of the pipe: Pipe.toString() */
277
+ pipe: string;
278
+
279
+ /** the result that pipe returned */
280
+ result?: any;
281
+ }
282
+
283
+ /**
284
+ * Represents a step in a test.
285
+ */
286
+ interface Step {
287
+ category: string;
288
+ title: string;
289
+ duration: number;
290
+ steps?: Step[];
291
+ error?: any;
292
+ }
293
+
294
+ declare global {
295
+ namespace NodeJS {
296
+ interface Global {
297
+ testomatioArtifacts?: any;
298
+ testomatioDataStore?: any;
299
+ TESTOMATIO_LOGGER_CONSOLE_INTERCEPTED?: boolean;
300
+ testomatioTestTitle?: string;
301
+ }
302
+ }
303
+ }
304
+
305
+ interface WebdriverIOError {
306
+ name: string;
307
+ message: string;
308
+ stack: string;
309
+ }
310
+
311
+ interface WebdriverIOBDDTest {
312
+ type: string;
313
+ start: string;
314
+ end: string;
315
+ _duration: number;
316
+ uid: string;
317
+ cid: string;
318
+ title: string;
319
+ fullTitle: string;
320
+ output: string[];
321
+ retries: number;
322
+ parent: string;
323
+ state: string;
324
+ errors: WebdriverIOError[];
325
+ error: WebdriverIOError;
326
+ }
327
+
328
+ interface WebdriverIOHook {
329
+ type: string;
330
+ start: string;
331
+ end: string;
332
+ _duration: number;
333
+ uid: string;
334
+ cid: string;
335
+ title: string;
336
+ parent: string;
337
+ errors: string[];
338
+ }
339
+
340
+ export interface WebdriverIOScenario {
341
+ type: string;
342
+ start: string;
343
+ end: string;
344
+ _duration: number;
345
+ uid: string;
346
+ cid: string;
347
+ file: string;
348
+ title: string;
349
+ fullTitle: string;
350
+ tags: { name: string; astNodeId: string }[];
351
+ tests: WebdriverIOBDDTest[];
352
+ hooks: WebdriverIOHook[];
353
+ suites: any[];
354
+ parent: string;
355
+ hooksAndTests: (WebdriverIOHook | WebdriverIOBDDTest)[];
356
+ description: string;
357
+ }
358
+
359
+ export type {
360
+ Suite as VitestSuite,
361
+ Test as VitestTest,
362
+ File as VitestTestFile,
363
+ TestLogs as VitestTestLogs,
364
+ } from './vitest.types';
@@ -0,0 +1,93 @@
1
+ type RunMode = 'run' | 'skip' | 'only' | 'todo';
2
+ type TaskState = RunMode | 'pass' | 'fail';
3
+ type Task = Test | Suite | File;
4
+
5
+ interface File extends Suite {
6
+ filepath: string;
7
+ collectDuration?: number;
8
+ setupDuration?: number;
9
+ }
10
+
11
+ interface Suite extends TaskBase {
12
+ type: 'suite';
13
+ tasks: Task[];
14
+ filepath?: string;
15
+ projectName: string;
16
+ }
17
+
18
+ type ErrorWithDiff = {
19
+ cause: string;
20
+ message: string;
21
+ name: string;
22
+ nameStr?: string;
23
+ stack?: string;
24
+ stackStr?: string;
25
+ stacks?: {
26
+ method: string;
27
+ file: string;
28
+ line: number;
29
+ column: number;
30
+ };
31
+ showDiff?: boolean;
32
+ actual?: any;
33
+ expected?: any;
34
+ operator?: string;
35
+ type?: string;
36
+ frame?: string;
37
+ diff?: string;
38
+ codeFrame?: string;
39
+ };
40
+
41
+ interface TaskResult {
42
+ state: TaskState;
43
+ duration?: number;
44
+ startTime?: number;
45
+ heap?: number;
46
+ errors?: ErrorWithDiff[];
47
+ htmlError?: string;
48
+ hooks?: Partial<Record<'beforeAll' | 'afterAll' | 'beforeEach' | 'afterEach', TaskState>>;
49
+ retryCount?: number;
50
+ repeatCount?: number;
51
+ }
52
+
53
+ interface TaskBase {
54
+ id: string;
55
+ name: string;
56
+ mode: RunMode;
57
+ meta: {};
58
+ each?: boolean;
59
+ concurrent?: boolean;
60
+ shuffle?: boolean;
61
+ suite?: Suite;
62
+ file?: File;
63
+ result?: TaskResult;
64
+ retry?: number;
65
+ repeats?: number;
66
+ location?: {
67
+ line: number;
68
+ column: number;
69
+ };
70
+ }
71
+
72
+ export type TestLogs = {
73
+ content: string;
74
+ size: number;
75
+ taskId: string;
76
+ time: number;
77
+ type: 'stdout' | 'stderr';
78
+ };
79
+
80
+ type FileResult = {
81
+ duration: number;
82
+ hooks: {
83
+ beforeEach: TaskState;
84
+ afterEach: TaskState;
85
+ };
86
+ startTime: number;
87
+ state: TaskState;
88
+ };
89
+
90
+ export type Test = TaskBase & {
91
+ logs: TestLogs[];
92
+ type: 'test';
93
+ };