@testomatio/reporter 2.9.0 → 2.9.1-beta.1-allure-chunking

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.
@@ -64,3 +64,20 @@ export function parsePipeOptions(optionsStr?: string): any;
64
64
  * @returns {string} Empty string if no ids; otherwise the formatted output.
65
65
  */
66
66
  export function formatFilterListIds(ids: string[], format: "grep" | "json" | "newline" | "ids"): string;
67
+ /**
68
+ * Calculate the approximate size of data in bytes (JSON stringified, UTF-8 encoded length).
69
+ * @param {Object} data - Data to measure
70
+ * @returns {number} Size in bytes
71
+ */
72
+ export function getObjectSize(data: any): number;
73
+ /**
74
+ * Split a tests array into chunks bounded by serialized size.
75
+ * Used by the XML and Allure readers so both upload tests with identical batching:
76
+ * each chunk becomes a single batch request (manual batch mode), which keeps requests
77
+ * under the size limit and guarantees every test is sent exactly once.
78
+ *
79
+ * @param {Array} tests - Array of tests to split
80
+ * @param {number} [maxSizeBytes=1048576] - Maximum serialized size per chunk (default 1MB)
81
+ * @returns {Array<Array>} Array of test chunks
82
+ */
83
+ export function splitTestsIntoChunks(tests: any[], maxSizeBytes?: number): Array<any[]>;
@@ -8,6 +8,8 @@ exports.statusEmoji = statusEmoji;
8
8
  exports.fullName = fullName;
9
9
  exports.parsePipeOptions = parsePipeOptions;
10
10
  exports.formatFilterListIds = formatFilterListIds;
11
+ exports.getObjectSize = getObjectSize;
12
+ exports.splitTestsIntoChunks = splitTestsIntoChunks;
11
13
  const log_js_1 = require("./log.js");
12
14
  /**
13
15
  * Set S3 credentials from the provided artifacts object.
@@ -162,6 +164,45 @@ function parsePipeOptions(optionsStr) {
162
164
  }
163
165
  return options;
164
166
  }
167
+ /**
168
+ * Calculate the approximate size of data in bytes (JSON stringified, UTF-8 encoded length).
169
+ * @param {Object} data - Data to measure
170
+ * @returns {number} Size in bytes
171
+ */
172
+ function getObjectSize(data) {
173
+ const body = JSON.stringify(data);
174
+ return new TextEncoder().encode(body).length;
175
+ }
176
+ /**
177
+ * Split a tests array into chunks bounded by serialized size.
178
+ * Used by the XML and Allure readers so both upload tests with identical batching:
179
+ * each chunk becomes a single batch request (manual batch mode), which keeps requests
180
+ * under the size limit and guarantees every test is sent exactly once.
181
+ *
182
+ * @param {Array} tests - Array of tests to split
183
+ * @param {number} [maxSizeBytes=1048576] - Maximum serialized size per chunk (default 1MB)
184
+ * @returns {Array<Array>} Array of test chunks
185
+ */
186
+ function splitTestsIntoChunks(tests, maxSizeBytes = 1 * 1024 * 1024) {
187
+ const chunks = [];
188
+ let currentChunk = [];
189
+ let currentChunkSize = 0;
190
+ for (const test of tests) {
191
+ const testSize = getObjectSize(test);
192
+ const wouldExceedSize = currentChunkSize + testSize > maxSizeBytes;
193
+ if (wouldExceedSize && currentChunk.length > 0) {
194
+ chunks.push(currentChunk);
195
+ currentChunk = [];
196
+ currentChunkSize = 0;
197
+ }
198
+ currentChunk.push(test);
199
+ currentChunkSize += testSize;
200
+ }
201
+ if (currentChunk.length > 0) {
202
+ chunks.push(currentChunk);
203
+ }
204
+ return chunks;
205
+ }
165
206
  /**
166
207
  * Format a list of test IDs for `--filter-list` machine-readable output.
167
208
  * Used when the CLI `--format` option is passed,
@@ -198,3 +239,7 @@ module.exports.fullName = fullName;
198
239
  module.exports.parsePipeOptions = parsePipeOptions;
199
240
 
200
241
  module.exports.formatFilterListIds = formatFilterListIds;
242
+
243
+ module.exports.getObjectSize = getObjectSize;
244
+
245
+ module.exports.splitTestsIntoChunks = splitTestsIntoChunks;
@@ -324,6 +324,15 @@ const fetchSourceCode = (contents, opts = {}) => {
324
324
  if (lineIndex === -1)
325
325
  lineIndex = lines.findIndex(l => l.includes(`${title}(`));
326
326
  }
327
+ else if (opts.lang === 'kotlin') {
328
+ lineIndex = lines.findIndex(l => l.includes(`fun test${title}`));
329
+ if (lineIndex === -1)
330
+ lineIndex = lines.findIndex(l => l.includes(`@DisplayName("${title}`));
331
+ if (lineIndex === -1)
332
+ lineIndex = lines.findIndex(l => l.includes(`fun ${title}`));
333
+ if (lineIndex === -1)
334
+ lineIndex = lines.findIndex(l => l.includes(`${title}(`));
335
+ }
327
336
  else if (opts.lang === 'csharp') {
328
337
  // Find the method declaration line
329
338
  let methodLineIndex = lines.findIndex(l => l.includes(`public void ${title}(`));
@@ -93,7 +93,6 @@ declare class XmlReader {
93
93
  pipes: any;
94
94
  uploadData(): Promise<any[]>;
95
95
  _finishRun(): Promise<any[]>;
96
- #private;
97
96
  }
98
97
  import { XMLParser } from 'fast-xml-parser';
99
98
  import { S3Uploader } from './uploader.js';
package/lib/xmlReader.js CHANGED
@@ -14,6 +14,7 @@ const url_1 = require("url");
14
14
  const nunit_parser_js_1 = require("./junit-adapter/nunit-parser.js");
15
15
  const utils_js_1 = require("./utils/utils.js");
16
16
  const index_js_1 = require("./pipe/index.js");
17
+ const pipe_utils_js_1 = require("./utils/pipe_utils.js");
17
18
  const index_js_2 = __importDefault(require("./junit-adapter/index.js"));
18
19
  const config_js_1 = require("./config.js");
19
20
  const uploader_js_1 = require("./uploader.js");
@@ -474,43 +475,6 @@ class XmlReader {
474
475
  this.uploader.checkEnabled();
475
476
  return run;
476
477
  }
477
- /**
478
- * Calculate the approximate size of data in bytes (JSON stringified length)
479
- * @param {Object} data - Data to measure
480
- * @returns {number} Size in bytes
481
- */
482
- #getObjectSize(data) {
483
- const body = JSON.stringify(data);
484
- return new TextEncoder().encode(body).length;
485
- }
486
- /**
487
- * Split tests array into chunks based on data size
488
- * @param {Array} tests - Array of tests to split
489
- * @returns {Array<Array>} Array of test chunks
490
- */
491
- #splitTestsIntoChunks(tests) {
492
- const maxSizeBytes = 1 * 1024 * 1024;
493
- const chunks = [];
494
- let currentChunk = [];
495
- let currentChunkSize = 0;
496
- for (const test of tests) {
497
- const testSize = this.#getObjectSize(test);
498
- const wouldExceedSize = currentChunkSize + testSize > maxSizeBytes;
499
- if (wouldExceedSize) {
500
- if (currentChunk.length > 0) {
501
- chunks.push(currentChunk);
502
- }
503
- currentChunk = [];
504
- currentChunkSize = 0;
505
- }
506
- currentChunk.push(test);
507
- currentChunkSize += testSize;
508
- }
509
- if (currentChunk.length > 0) {
510
- chunks.push(currentChunk);
511
- }
512
- return chunks;
513
- }
514
478
  async uploadData() {
515
479
  await this.uploadArtifacts();
516
480
  this.calculateStats();
@@ -531,7 +495,7 @@ class XmlReader {
531
495
  };
532
496
  return Promise.all(this.pipes.map(p => p.finishRun(finishData)));
533
497
  }
534
- const testChunks = this.#splitTestsIntoChunks(this.tests);
498
+ const testChunks = (0, pipe_utils_js_1.splitTestsIntoChunks)(this.tests);
535
499
  const totalChunks = testChunks.length;
536
500
  const totalTests = this.tests.length;
537
501
  debug(`Split ${totalTests} tests into ${totalChunks} chunks (max 1MB per chunk)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.9.0",
3
+ "version": "2.9.1-beta.1-allure-chunking",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"