@testomatio/reporter 2.0.1-beta.3 → 2.0.1-beta.5-timestamp

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 (148) hide show
  1. package/lib/adapter/codecept.js +335 -293
  2. package/lib/adapter/cucumber/current.js +203 -195
  3. package/lib/adapter/cucumber/legacy.js +155 -130
  4. package/lib/adapter/cucumber.js +16 -5
  5. package/lib/adapter/cypress-plugin/index.js +105 -91
  6. package/lib/adapter/jasmine.js +53 -54
  7. package/lib/adapter/jest.js +99 -97
  8. package/lib/adapter/mocha.js +141 -112
  9. package/lib/adapter/playwright.js +231 -199
  10. package/lib/adapter/vitest.js +149 -150
  11. package/lib/adapter/webdriver.js +121 -144
  12. package/lib/bin/cli.js +211 -229
  13. package/lib/bin/reportXml.js +52 -51
  14. package/lib/bin/startTest.js +95 -83
  15. package/lib/bin/uploadArtifacts.js +61 -56
  16. package/lib/client.js +465 -424
  17. package/lib/config.js +23 -18
  18. package/lib/constants.js +44 -50
  19. package/lib/data-storage.js +188 -216
  20. package/lib/junit-adapter/adapter.js +20 -17
  21. package/lib/junit-adapter/csharp.js +14 -28
  22. package/lib/junit-adapter/index.js +25 -27
  23. package/lib/junit-adapter/java.js +53 -41
  24. package/lib/junit-adapter/javascript.js +27 -30
  25. package/lib/junit-adapter/python.js +37 -38
  26. package/lib/junit-adapter/ruby.js +8 -11
  27. package/lib/output.js +52 -44
  28. package/lib/pipe/bitbucket.js +230 -223
  29. package/lib/pipe/csv.js +126 -113
  30. package/lib/pipe/debug.js +99 -118
  31. package/lib/pipe/github.js +213 -218
  32. package/lib/pipe/gitlab.js +206 -183
  33. package/lib/pipe/html.js +321 -258
  34. package/lib/pipe/index.js +66 -94
  35. package/lib/pipe/testomatio.js +474 -429
  36. package/lib/reporter-functions.js +26 -28
  37. package/lib/reporter.js +29 -34
  38. package/lib/services/artifacts.js +51 -55
  39. package/lib/services/index.js +12 -14
  40. package/lib/services/key-values.js +53 -56
  41. package/lib/services/logger.js +245 -226
  42. package/lib/template/testomatio.hbs +1366 -1026
  43. package/lib/uploader.js +364 -295
  44. package/lib/utils/pipe_utils.js +85 -89
  45. package/lib/utils/utils.js +307 -398
  46. package/lib/xmlReader.js +532 -525
  47. package/package.json +21 -64
  48. package/lib/adapter/codecept.d.ts +0 -2
  49. package/lib/adapter/cucumber/current.d.ts +0 -14
  50. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  51. package/lib/adapter/cucumber.d.ts +0 -2
  52. package/lib/adapter/cypress-plugin/index.d.ts +0 -2
  53. package/lib/adapter/jasmine.d.ts +0 -11
  54. package/lib/adapter/jest.d.ts +0 -13
  55. package/lib/adapter/mocha.d.ts +0 -2
  56. package/lib/adapter/nightwatch.d.ts +0 -4
  57. package/lib/adapter/nightwatch.js +0 -80
  58. package/lib/adapter/playwright.d.ts +0 -14
  59. package/lib/adapter/vitest.d.ts +0 -35
  60. package/lib/adapter/webdriver.d.ts +0 -24
  61. package/lib/bin/cli.d.ts +0 -2
  62. package/lib/bin/reportXml.d.ts +0 -2
  63. package/lib/bin/startTest.d.ts +0 -2
  64. package/lib/bin/uploadArtifacts.d.ts +0 -2
  65. package/lib/client.d.ts +0 -76
  66. package/lib/config.d.ts +0 -1
  67. package/lib/constants.d.ts +0 -25
  68. package/lib/data-storage.d.ts +0 -34
  69. package/lib/junit-adapter/adapter.d.ts +0 -9
  70. package/lib/junit-adapter/csharp.d.ts +0 -5
  71. package/lib/junit-adapter/index.d.ts +0 -3
  72. package/lib/junit-adapter/java.d.ts +0 -5
  73. package/lib/junit-adapter/javascript.d.ts +0 -4
  74. package/lib/junit-adapter/python.d.ts +0 -5
  75. package/lib/junit-adapter/ruby.d.ts +0 -4
  76. package/lib/output.d.ts +0 -11
  77. package/lib/package.json +0 -3
  78. package/lib/pipe/bitbucket.d.ts +0 -25
  79. package/lib/pipe/csv.d.ts +0 -47
  80. package/lib/pipe/debug.d.ts +0 -29
  81. package/lib/pipe/github.d.ts +0 -30
  82. package/lib/pipe/gitlab.d.ts +0 -25
  83. package/lib/pipe/html.d.ts +0 -35
  84. package/lib/pipe/index.d.ts +0 -1
  85. package/lib/pipe/testomatio.d.ts +0 -71
  86. package/lib/replay.d.ts +0 -31
  87. package/lib/replay.js +0 -237
  88. package/lib/reporter-functions.d.ts +0 -34
  89. package/lib/reporter.d.ts +0 -232
  90. package/lib/services/artifacts.d.ts +0 -33
  91. package/lib/services/index.d.ts +0 -9
  92. package/lib/services/key-values.d.ts +0 -27
  93. package/lib/services/logger.d.ts +0 -64
  94. package/lib/uploader.d.ts +0 -60
  95. package/lib/utils/pipe_utils.d.ts +0 -41
  96. package/lib/utils/utils.d.ts +0 -54
  97. package/lib/xmlReader.d.ts +0 -92
  98. package/src/adapter/codecept.js +0 -373
  99. package/src/adapter/cucumber/current.js +0 -228
  100. package/src/adapter/cucumber/legacy.js +0 -158
  101. package/src/adapter/cucumber.js +0 -4
  102. package/src/adapter/cypress-plugin/index.js +0 -110
  103. package/src/adapter/jasmine.js +0 -60
  104. package/src/adapter/jest.js +0 -107
  105. package/src/adapter/mocha.cjs +0 -2
  106. package/src/adapter/mocha.js +0 -156
  107. package/src/adapter/nightwatch.js +0 -88
  108. package/src/adapter/playwright.js +0 -254
  109. package/src/adapter/vitest.js +0 -183
  110. package/src/adapter/webdriver.js +0 -142
  111. package/src/bin/cli.js +0 -348
  112. package/src/bin/reportXml.js +0 -77
  113. package/src/bin/startTest.js +0 -124
  114. package/src/bin/uploadArtifacts.js +0 -91
  115. package/src/client.js +0 -508
  116. package/src/config.js +0 -30
  117. package/src/constants.js +0 -53
  118. package/src/data-storage.js +0 -204
  119. package/src/junit-adapter/adapter.js +0 -23
  120. package/src/junit-adapter/csharp.js +0 -28
  121. package/src/junit-adapter/index.js +0 -28
  122. package/src/junit-adapter/java.js +0 -58
  123. package/src/junit-adapter/javascript.js +0 -31
  124. package/src/junit-adapter/python.js +0 -42
  125. package/src/junit-adapter/ruby.js +0 -10
  126. package/src/output.js +0 -57
  127. package/src/pipe/bitbucket.js +0 -252
  128. package/src/pipe/csv.js +0 -140
  129. package/src/pipe/debug.js +0 -119
  130. package/src/pipe/github.js +0 -232
  131. package/src/pipe/gitlab.js +0 -247
  132. package/src/pipe/html.js +0 -373
  133. package/src/pipe/index.js +0 -71
  134. package/src/pipe/testomatio.js +0 -504
  135. package/src/replay.js +0 -245
  136. package/src/reporter-functions.js +0 -55
  137. package/src/reporter.cjs_decprecated +0 -21
  138. package/src/reporter.js +0 -33
  139. package/src/services/artifacts.js +0 -59
  140. package/src/services/index.js +0 -13
  141. package/src/services/key-values.js +0 -59
  142. package/src/services/logger.js +0 -315
  143. package/src/template/emptyData.svg +0 -23
  144. package/src/template/testomatio.hbs +0 -1081
  145. package/src/uploader.js +0 -376
  146. package/src/utils/pipe_utils.js +0 -119
  147. package/src/utils/utils.js +0 -416
  148. package/src/xmlReader.js +0 -614
package/lib/pipe/csv.d.ts DELETED
@@ -1,47 +0,0 @@
1
- export default CsvPipe;
2
- export type Pipe = import("../../types/types.js").Pipe;
3
- export type TestData = import("../../types/types.js").TestData;
4
- /**
5
- * @typedef {import('../../types/types.js').Pipe} Pipe
6
- * @typedef {import('../../types/types.js').TestData} TestData
7
- * @class CsvPipe
8
- * @implements {Pipe}
9
- */
10
- declare class CsvPipe implements Pipe {
11
- constructor(params: any, store: any);
12
- store: any;
13
- title: any;
14
- results: any[];
15
- outputDir: string;
16
- defaultReportName: string;
17
- csvFilename: string;
18
- isEnabled: boolean;
19
- outputFile: string;
20
- prepareRun(): Promise<void>;
21
- createRun(): Promise<void>;
22
- updateRun(): void;
23
- /**
24
- * Create a folder that will contain the exported files
25
- */
26
- checkExportDir(): void;
27
- /**
28
- * Save data to the csv file.
29
- * @param {Object} data - data that will be added to the CSV file.
30
- * Example: [{suite_title: "Suite #1", test: "Test-case-1", message: "Test msg"}]
31
- * @param {Object} headers - csv file headers. Example: [{ id: 'suite_title', title: 'Suite_title' }]
32
- */
33
- saveToCsv(data: any, headers: any): Promise<void>;
34
- /**
35
- * Add test data to the result array for saving. As a result of this function, we get a result object to save.
36
- * @param {Object} test - object which includes each test entry.
37
- */
38
- addTest(test: any): void;
39
- /**
40
- * @param {{ tests?: TestData[] }} runParams
41
- * @returns {Promise<void>}
42
- */
43
- finishRun(runParams: {
44
- tests?: TestData[];
45
- }): Promise<void>;
46
- toString(): string;
47
- }
@@ -1,29 +0,0 @@
1
- export class DebugPipe {
2
- constructor(params: any, store: any);
3
- params: any;
4
- store: any;
5
- isEnabled: boolean;
6
- batch: {
7
- isEnabled: any;
8
- intervalFunction: any;
9
- intervalTime: number;
10
- tests: any[];
11
- batchIndex: number;
12
- };
13
- logFilePath: string;
14
- testomatioEnvVars: {};
15
- batchUpload(): Promise<void>;
16
- /**
17
- * Logs data to a file if logging is enabled.
18
- *
19
- * @param {Object} logData - The data to be logged.
20
- * @returns {Promise<void>} A promise that resolves when the log data has been appended to the file.
21
- */
22
- logToFile(logData: any): Promise<void>;
23
- lastActionTimestamp: number;
24
- prepareRun(opts: any): Promise<any[]>;
25
- createRun(params?: {}): Promise<{}>;
26
- addTest(data: any): Promise<void>;
27
- finishRun(params: any): Promise<void>;
28
- toString(): string;
29
- }
@@ -1,30 +0,0 @@
1
- export default GitHubPipe;
2
- export type Pipe = import("../../types/types.js").Pipe;
3
- export type TestData = import("../../types/types.js").TestData;
4
- /**
5
- * @typedef {import('../../types/types.js').Pipe} Pipe
6
- * @typedef {import('../../types/types.js').TestData} TestData
7
- * @class GitHubPipe
8
- * @implements {Pipe}
9
- */
10
- declare class GitHubPipe implements Pipe {
11
- constructor(params: any, store?: {});
12
- isEnabled: boolean;
13
- store: {};
14
- tests: any[];
15
- token: any;
16
- ref: string;
17
- repo: string;
18
- jobKey: string;
19
- hiddenCommentData: string;
20
- issue: number;
21
- start: Date;
22
- prepareRun(): Promise<void>;
23
- createRun(): Promise<void>;
24
- addTest(test: any): void;
25
- finishRun(runParams: any): Promise<void>;
26
- octokit: import("@octokit/core").Octokit & import("@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.js").RestEndpointMethods & import("@octokit/plugin-rest-endpoint-methods").Api & {
27
- paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
28
- };
29
- toString(): string;
30
- }
@@ -1,25 +0,0 @@
1
- export default GitLabPipe;
2
- export type Pipe = import("../../types/types.js").Pipe;
3
- export type TestData = import("../../types/types.js").TestData;
4
- /**
5
- * @class GitLabPipe
6
- * @typedef {import('../../types/types.js').Pipe} Pipe
7
- * @typedef {import('../../types/types.js').TestData} TestData
8
- */
9
- declare class GitLabPipe {
10
- constructor(params: any, store?: {});
11
- isEnabled: boolean;
12
- ENV: NodeJS.ProcessEnv;
13
- store: {};
14
- tests: any[];
15
- token: any;
16
- hiddenCommentData: string;
17
- client: Gaxios;
18
- prepareRun(): Promise<void>;
19
- createRun(): Promise<void>;
20
- addTest(test: any): void;
21
- finishRun(runParams: any): Promise<void>;
22
- toString(): string;
23
- updateRun(): void;
24
- }
25
- import { Gaxios } from 'gaxios';
@@ -1,35 +0,0 @@
1
- export default HtmlPipe;
2
- declare class HtmlPipe {
3
- constructor(params: any, store?: {});
4
- store: {};
5
- title: any;
6
- apiKey: any;
7
- isHtml: string;
8
- isEnabled: boolean;
9
- htmlOutputPath: string;
10
- fullHtmlOutputPath: string;
11
- filenameMsg: string;
12
- tests: any[];
13
- htmlReportDir: string;
14
- htmlReportName: string;
15
- templateFolderPath: string;
16
- templateHtmlPath: string;
17
- createRun(): Promise<void>;
18
- prepareRun(): Promise<void>;
19
- updateRun(): void;
20
- /**
21
- * Add test data to the result array for saving. As a result of this function, we get a result object to save.
22
- * @param {import('../../types/types.js').RunData} test - object which includes each test entry.
23
- */
24
- addTest(test: import("../../types/types.js").RunData): void;
25
- finishRun(runParams: any): Promise<void>;
26
- /**
27
- * Generates an HTML report based on provided test data and a template.
28
- * @param {object} opts - Test options used to generate the HTML report:
29
- * runParams, tests, outputPath, templatePath
30
- * @returns {void} - This function does not return anything.
31
- */
32
- buildReport(opts: object): void;
33
- toString(): string;
34
- #private;
35
- }
@@ -1 +0,0 @@
1
- export function pipesFactory(params: any, opts: any): Promise<any[]>;
@@ -1,71 +0,0 @@
1
- export default TestomatioPipe;
2
- export type Pipe = import("../../types/types.js").Pipe;
3
- export type TestData = import("../../types/types.js").TestData;
4
- /**
5
- * @typedef {import('../../types/types.js').Pipe} Pipe
6
- * @typedef {import('../../types/types.js').TestData} TestData
7
- * @class TestomatioPipe
8
- * @implements {Pipe}
9
- */
10
- declare class TestomatioPipe implements Pipe {
11
- constructor(params: any, store: any);
12
- batch: {
13
- isEnabled: any;
14
- intervalFunction: any;
15
- intervalTime: number;
16
- tests: any[];
17
- batchIndex: number;
18
- numberOfTimesCalledWithoutTests: number;
19
- };
20
- retriesTimestamps: any[];
21
- reportingCanceledDueToReqFailures: boolean;
22
- notReportedTestsCount: number;
23
- isEnabled: boolean;
24
- url: any;
25
- apiKey: any;
26
- parallel: any;
27
- store: any;
28
- title: any;
29
- sharedRun: boolean;
30
- sharedRunTimeout: boolean;
31
- groupTitle: any;
32
- env: string;
33
- label: string;
34
- client: Gaxios;
35
- proceed: string;
36
- jiraId: string;
37
- runId: any;
38
- createNewTests: any;
39
- hasUnmatchedTests: boolean;
40
- requestFailures: number;
41
- /**
42
- * Asynchronously prepares and retrieves the Testomat.io test grepList based on the provided options.
43
- * @param {Object} opts - The options for preparing the test grepList.
44
- * @returns {Promise<string[]>} - An array containing the retrieved
45
- * test grepList, or an empty array if no tests are found or the request is disabled.
46
- * @throws {Error} - Throws an error if there was a problem while making the request.
47
- */
48
- prepareRun(opts: any): Promise<string[]>;
49
- /**
50
- * Creates a new run on Testomat.io
51
- * @param {{isBatchEnabled?: boolean}} params
52
- * @returns Promise<void>
53
- */
54
- createRun(params?: {
55
- isBatchEnabled?: boolean;
56
- }): Promise<void>;
57
- runUrl: string;
58
- runPublicUrl: any;
59
- /**
60
- * Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
61
- */
62
- addTest(data: any): Promise<void | import("gaxios").GaxiosResponse<any>>;
63
- /**
64
- * @param {import('../../types/types.js').RunData} params
65
- * @returns
66
- */
67
- finishRun(params: import("../../types/types.js").RunData): Promise<void>;
68
- toString(): string;
69
- #private;
70
- }
71
- import { Gaxios } from 'gaxios';
package/lib/replay.d.ts DELETED
@@ -1,31 +0,0 @@
1
- export class Replay {
2
- constructor(options?: {});
3
- apiKey: any;
4
- dryRun: any;
5
- onProgress: any;
6
- onLog: any;
7
- onError: any;
8
- /**
9
- * Get the default debug file path
10
- * @returns {string} Path to the latest debug file
11
- */
12
- getDefaultDebugFile(): string;
13
- /**
14
- * Parse a debug file and extract test data
15
- * @param {string} debugFile - Path to the debug file
16
- * @returns {Object} Parsed debug data
17
- */
18
- parseDebugFile(debugFile: string): any;
19
- /**
20
- * Restore environment variables from debug data
21
- * @param {Object} envVars - Environment variables to restore
22
- */
23
- restoreEnvironmentVariables(envVars: any): void;
24
- /**
25
- * Replay test data to Testomat.io
26
- * @param {string} debugFile - Path to debug file (optional, uses default if not provided)
27
- * @returns {Promise<Object>} Replay results
28
- */
29
- replay(debugFile: string): Promise<any>;
30
- }
31
- export default Replay;
package/lib/replay.js DELETED
@@ -1,237 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Replay = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const os_1 = __importDefault(require("os"));
10
- const client_js_1 = __importDefault(require("./client.js"));
11
- const constants_js_1 = require("./constants.js");
12
- const config_js_1 = require("./config.js");
13
- class Replay {
14
- constructor(options = {}) {
15
- this.apiKey = options.apiKey || config_js_1.config.TESTOMATIO || undefined;
16
- this.dryRun = options.dryRun || false;
17
- this.onProgress = options.onProgress || (() => { });
18
- this.onLog = options.onLog || console.log;
19
- this.onError = options.onError || console.error;
20
- }
21
- /**
22
- * Get the default debug file path
23
- * @returns {string} Path to the latest debug file
24
- */
25
- getDefaultDebugFile() {
26
- return path_1.default.join(os_1.default.tmpdir(), 'testomatio.debug.latest.json');
27
- }
28
- /**
29
- * Parse a debug file and extract test data
30
- * @param {string} debugFile - Path to the debug file
31
- * @returns {Object} Parsed debug data
32
- */
33
- parseDebugFile(debugFile) {
34
- if (!fs_1.default.existsSync(debugFile)) {
35
- throw new Error(`Debug file not found: ${debugFile}`);
36
- }
37
- const fileContent = fs_1.default.readFileSync(debugFile, 'utf-8');
38
- const lines = fileContent.trim().split('\n').filter(line => line.trim() !== '');
39
- if (lines.length === 0) {
40
- throw new Error('Debug file is empty');
41
- }
42
- let runParams = {};
43
- let finishParams = {};
44
- let parseErrors = 0;
45
- const testsMap = new Map(); // Use Map to deduplicate by rid
46
- const testsWithoutRid = []; // For tests without rid (backward compatibility)
47
- const envVars = {};
48
- // Parse debug file line by line
49
- for (const [lineIndex, line] of lines.entries()) {
50
- try {
51
- const logEntry = JSON.parse(line);
52
- if (logEntry.data === 'variables' && logEntry.testomatioEnvVars) {
53
- Object.assign(envVars, logEntry.testomatioEnvVars);
54
- }
55
- else if (logEntry.action === 'createRun') {
56
- runParams = logEntry.params || {};
57
- }
58
- else if (logEntry.action === 'addTestsBatch' && logEntry.tests) {
59
- // Process each test in the batch
60
- for (const test of logEntry.tests) {
61
- if (test.rid) {
62
- // Handle tests with rid (deduplicate)
63
- const existingTest = testsMap.get(test.rid);
64
- if (existingTest) {
65
- // Merge test data - prioritize non-null/non-empty values
66
- const mergedTest = { ...existingTest };
67
- Object.keys(test).forEach(key => {
68
- if (test[key] !== null && test[key] !== undefined) {
69
- if (key === 'files' && Array.isArray(test[key]) && test[key].length > 0) {
70
- // Merge files arrays
71
- mergedTest.files = [...(existingTest.files || []), ...test[key]];
72
- }
73
- else if (key === 'artifacts' && Array.isArray(test[key]) && test[key].length > 0) {
74
- // Merge artifacts arrays
75
- mergedTest.artifacts = [...(existingTest.artifacts || []), ...test[key]];
76
- }
77
- else if (existingTest[key] === null || existingTest[key] === undefined ||
78
- (Array.isArray(existingTest[key]) && existingTest[key].length === 0)) {
79
- // Use new value if existing is null/undefined/empty array
80
- mergedTest[key] = test[key];
81
- }
82
- }
83
- });
84
- testsMap.set(test.rid, mergedTest);
85
- }
86
- else {
87
- testsMap.set(test.rid, { ...test });
88
- }
89
- }
90
- else {
91
- // Handle tests without rid (no deduplication)
92
- testsWithoutRid.push({ ...test });
93
- }
94
- }
95
- }
96
- else if (logEntry.action === 'addTest' && logEntry.testId) {
97
- const test = logEntry.testId;
98
- if (test.rid) {
99
- // Handle tests with rid (deduplicate)
100
- const existingTest = testsMap.get(test.rid);
101
- if (existingTest) {
102
- // Merge with existing test
103
- const mergedTest = { ...existingTest, ...test };
104
- testsMap.set(test.rid, mergedTest);
105
- }
106
- else {
107
- testsMap.set(test.rid, { ...test });
108
- }
109
- }
110
- else {
111
- // Handle tests without rid (no deduplication)
112
- testsWithoutRid.push({ ...test });
113
- }
114
- }
115
- else if (logEntry.actions === 'finishRun') {
116
- finishParams = logEntry.params || {};
117
- }
118
- }
119
- catch (err) {
120
- parseErrors++;
121
- if (parseErrors <= 3) {
122
- // Only show first 3 parse errors
123
- this.onError(`Failed to parse line ${lineIndex + 1}: ${line.substring(0, 100)}...`);
124
- }
125
- }
126
- }
127
- if (parseErrors > 3) {
128
- this.onError(`${parseErrors - 3} more parse errors occurred`);
129
- }
130
- // Combine tests with rid and tests without rid
131
- const allTests = [...Array.from(testsMap.values()), ...testsWithoutRid];
132
- return {
133
- runParams,
134
- finishParams,
135
- tests: allTests,
136
- envVars,
137
- parseErrors,
138
- totalLines: lines.length
139
- };
140
- }
141
- /**
142
- * Restore environment variables from debug data
143
- * @param {Object} envVars - Environment variables to restore
144
- */
145
- restoreEnvironmentVariables(envVars) {
146
- // Only restore env vars that aren't already set (don't override current values)
147
- Object.keys(envVars).forEach(key => {
148
- if (process.env[key] === undefined || process.env[key] === '') {
149
- process.env[key] = envVars[key];
150
- }
151
- });
152
- }
153
- /**
154
- * Replay test data to Testomat.io
155
- * @param {string} debugFile - Path to debug file (optional, uses default if not provided)
156
- * @returns {Promise<Object>} Replay results
157
- */
158
- async replay(debugFile) {
159
- if (!debugFile) {
160
- debugFile = this.getDefaultDebugFile();
161
- }
162
- if (!this.apiKey) {
163
- throw new Error('TESTOMATIO API key not found. Set TESTOMATIO environment variable.');
164
- }
165
- this.onLog(`Replaying data from debug file: ${debugFile}`);
166
- // Parse the debug file
167
- const debugData = this.parseDebugFile(debugFile);
168
- const { runParams, finishParams, tests, envVars } = debugData;
169
- this.onLog(`Found ${tests.length} tests to replay`);
170
- if (tests.length === 0) {
171
- throw new Error('No test data found in debug file');
172
- }
173
- // Restore environment variables
174
- this.restoreEnvironmentVariables(envVars);
175
- if (this.dryRun) {
176
- return {
177
- success: true,
178
- testsCount: tests.length,
179
- runParams,
180
- finishParams,
181
- envVars,
182
- dryRun: true
183
- };
184
- }
185
- // Create client and restore the run
186
- const client = new client_js_1.default({
187
- apiKey: this.apiKey,
188
- isBatchEnabled: true,
189
- ...runParams,
190
- });
191
- this.onLog('Publishing to run...');
192
- await client.createRun(runParams);
193
- // Send each test result
194
- let successCount = 0;
195
- let failureCount = 0;
196
- for (const [index, test] of tests.entries()) {
197
- try {
198
- await client.addTestRun(test.status, test);
199
- successCount++;
200
- this.onProgress({
201
- current: index + 1,
202
- total: tests.length,
203
- test,
204
- success: true
205
- });
206
- }
207
- catch (err) {
208
- failureCount++;
209
- this.onError(`Failed to send test ${index + 1}: ${err.message}`);
210
- this.onProgress({
211
- current: index + 1,
212
- total: tests.length,
213
- test,
214
- success: false,
215
- error: err.message
216
- });
217
- }
218
- }
219
- await client.updateRunStatus(finishParams.status || constants_js_1.STATUS.FINISHED, finishParams.parallel || false);
220
- const result = {
221
- success: true,
222
- testsCount: tests.length,
223
- successCount,
224
- failureCount,
225
- runParams,
226
- finishParams,
227
- envVars,
228
- runId: client.runId
229
- };
230
- this.onLog(`Successfully replayed ${successCount}/${tests.length} tests from debug file`);
231
- return result;
232
- }
233
- }
234
- exports.Replay = Replay;
235
- module.exports = Replay;
236
-
237
- module.exports.Replay = Replay;
@@ -1,34 +0,0 @@
1
- declare namespace _default {
2
- export { saveArtifact as artifact };
3
- export { logMessage as log };
4
- export { addStep as step };
5
- export { setKeyValue as keyValue };
6
- }
7
- export default _default;
8
- /**
9
- * Stores path to file as artifact and uploads it to the S3 storage
10
- * @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
11
- */
12
- declare function saveArtifact(data: string | {
13
- path: string;
14
- type: string;
15
- name: string;
16
- }, context?: any): void;
17
- /**
18
- * Attach log message(s) to the test report
19
- * @param string
20
- */
21
- declare function logMessage(...args: any[]): void;
22
- /**
23
- * Similar to "log" function but marks message in report as a step
24
- * @param {string} message
25
- */
26
- declare function addStep(message: string): void;
27
- /**
28
- * Add key-value pair(s) to the test report
29
- * @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
30
- * @param {string?} value
31
- */
32
- declare function setKeyValue(keyValue: {
33
- [key: string]: string;
34
- } | string, value?: string | null): void;