@testomatio/reporter 2.0.0-beta.1-xml → 2.0.0-beta.2-gaxios

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.
package/lib/reporter.d.ts CHANGED
@@ -8,7 +8,7 @@ export type log = typeof import("./reporter-functions.js");
8
8
  export const log: (...args: any[]) => void;
9
9
  export type logger = typeof import("./services/index.js");
10
10
  export const logger: {
11
- "__#12@#originalUserLogger": {
11
+ "__#13@#originalUserLogger": {
12
12
  assert(condition?: boolean, ...data: any[]): void;
13
13
  assert(value: any, message?: string, ...optionalParams: any[]): void;
14
14
  clear(): void;
@@ -53,13 +53,13 @@ export const logger: {
53
53
  profile(label?: string): void;
54
54
  profileEnd(label?: string): void;
55
55
  };
56
- "__#12@#userLoggerWithOverridenMethods": any;
56
+ "__#13@#userLoggerWithOverridenMethods": any;
57
57
  logLevel: string;
58
58
  step(strings: any, ...values: any[]): void;
59
59
  getLogs(context: string): string[];
60
- "__#12@#stringifyLogs"(...args: any[]): string;
60
+ "__#13@#stringifyLogs"(...args: any[]): string;
61
61
  _templateLiteralLog(strings: any, ...args: any[]): void;
62
- "__#12@#logWrapper"(argsArray: any, level: any): void;
62
+ "__#13@#logWrapper"(argsArray: any, level: any): void;
63
63
  assert(...args: any[]): void;
64
64
  debug(...args: any[]): void;
65
65
  error(...args: any[]): void;
@@ -83,7 +83,7 @@ export type step = typeof import("./reporter-functions.js");
83
83
  export const step: (message: string) => void;
84
84
  declare namespace _default {
85
85
  let testomatioLogger: {
86
- "__#12@#originalUserLogger": {
86
+ "__#13@#originalUserLogger": {
87
87
  assert(condition?: boolean, ...data: any[]): void;
88
88
  assert(value: any, message?: string, ...optionalParams: any[]): void;
89
89
  clear(): void;
@@ -128,13 +128,13 @@ declare namespace _default {
128
128
  profile(label?: string): void;
129
129
  profileEnd(label?: string): void;
130
130
  };
131
- "__#12@#userLoggerWithOverridenMethods": any;
131
+ "__#13@#userLoggerWithOverridenMethods": any;
132
132
  logLevel: string;
133
133
  step(strings: any, ...values: any[]): void;
134
134
  getLogs(context: string): string[];
135
- "__#12@#stringifyLogs"(...args: any[]): string;
135
+ "__#13@#stringifyLogs"(...args: any[]): string;
136
136
  _templateLiteralLog(strings: any, ...args: any[]): void;
137
- "__#12@#logWrapper"(argsArray: any, level: any): void;
137
+ "__#13@#logWrapper"(argsArray: any, level: any): void;
138
138
  assert(...args: any[]): void;
139
139
  debug(...args: any[]): void;
140
140
  error(...args: any[]): void;
@@ -157,7 +157,7 @@ declare namespace _default {
157
157
  }, context?: any) => void;
158
158
  let log: (...args: any[]) => void;
159
159
  let logger: {
160
- "__#12@#originalUserLogger": {
160
+ "__#13@#originalUserLogger": {
161
161
  assert(condition?: boolean, ...data: any[]): void;
162
162
  assert(value: any, message?: string, ...optionalParams: any[]): void;
163
163
  clear(): void;
@@ -202,13 +202,13 @@ declare namespace _default {
202
202
  profile(label?: string): void;
203
203
  profileEnd(label?: string): void;
204
204
  };
205
- "__#12@#userLoggerWithOverridenMethods": any;
205
+ "__#13@#userLoggerWithOverridenMethods": any;
206
206
  logLevel: string;
207
207
  step(strings: any, ...values: any[]): void;
208
208
  getLogs(context: string): string[];
209
- "__#12@#stringifyLogs"(...args: any[]): string;
209
+ "__#13@#stringifyLogs"(...args: any[]): string;
210
210
  _templateLiteralLog(strings: any, ...args: any[]): void;
211
- "__#12@#logWrapper"(argsArray: any, level: any): void;
211
+ "__#13@#logWrapper"(argsArray: any, level: any): void;
212
212
  assert(...args: any[]): void;
213
213
  debug(...args: any[]): void;
214
214
  error(...args: any[]): void;
@@ -3,7 +3,7 @@ export const artifactStorage: ArtifactStorage;
3
3
  * Artifact storage is supposed to store file paths
4
4
  */
5
5
  declare class ArtifactStorage {
6
- static "__#13@#instance": any;
6
+ static "__#14@#instance": any;
7
7
  /**
8
8
  * Singleton
9
9
  * @returns {ArtifactStorage}
@@ -1,6 +1,6 @@
1
1
  export const keyValueStorage: KeyValueStorage;
2
2
  declare class KeyValueStorage {
3
- static "__#14@#instance": any;
3
+ static "__#15@#instance": any;
4
4
  /**
5
5
  *
6
6
  * @returns {KeyValueStorage}
@@ -5,7 +5,7 @@ export const logger: Logger;
5
5
  * Supports different syntaxes to satisfy any user preferences.
6
6
  */
7
7
  declare class Logger {
8
- static "__#12@#instance": any;
8
+ static "__#13@#instance": any;
9
9
  /**
10
10
  *
11
11
  * @returns {Logger}
@@ -1,5 +1,3 @@
1
- export function getPackageVersion(): any;
2
- export const TEST_ID_REGEX: RegExp;
3
1
  export function ansiRegExp(): RegExp;
4
2
  export function isSameTest(test: any, t: any): boolean;
5
3
  export function fetchSourceCode(contents: any, opts?: {}): string;
@@ -36,8 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.TEST_ID_REGEX = void 0;
40
- exports.getPackageVersion = getPackageVersion;
39
+ exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = void 0;
41
40
  exports.formatStep = formatStep;
42
41
  exports.readLatestRunId = readLatestRunId;
43
42
  exports.removeColorCodes = removeColorCodes;
@@ -49,9 +48,7 @@ const fs_1 = __importDefault(require("fs"));
49
48
  const is_valid_path_1 = __importDefault(require("is-valid-path"));
50
49
  const debug_1 = __importDefault(require("debug"));
51
50
  const os_1 = __importDefault(require("os"));
52
- const url_2 = require("url");
53
51
  const debug = (0, debug_1.default)('@testomatio/reporter:util');
54
- // Use __dirname directly since we're compiling to CommonJS
55
52
  /**
56
53
  * @param {String} testTitle - Test title
57
54
  *
@@ -143,7 +140,7 @@ const fetchSourceCodeFromStackTrace = (stack = '') => {
143
140
  .join('\n');
144
141
  };
145
142
  exports.fetchSourceCodeFromStackTrace = fetchSourceCodeFromStackTrace;
146
- exports.TEST_ID_REGEX = /@T([\w\d]{8})/;
143
+ const TEST_ID_REGEX = /@T([\w\d]{8})/;
147
144
  const fetchIdFromCode = (code, opts = {}) => {
148
145
  const comments = code
149
146
  .split('\n')
@@ -157,11 +154,11 @@ const fetchIdFromCode = (code, opts = {}) => {
157
154
  return l.startsWith('// ');
158
155
  }
159
156
  });
160
- return comments.find(c => c.match(exports.TEST_ID_REGEX))?.match(exports.TEST_ID_REGEX)?.[1];
157
+ return comments.find(c => c.match(TEST_ID_REGEX))?.match(TEST_ID_REGEX)?.[1];
161
158
  };
162
159
  exports.fetchIdFromCode = fetchIdFromCode;
163
160
  const fetchIdFromOutput = output => {
164
- const TID_FULL_PATTERN = new RegExp(`tid:\\/\\/.*?(${exports.TEST_ID_REGEX.source})`);
161
+ const TID_FULL_PATTERN = new RegExp(`tid:\\/\\/.*?(${TEST_ID_REGEX.source})`);
165
162
  return output.match(TID_FULL_PATTERN)?.[2];
166
163
  };
167
164
  exports.fetchIdFromOutput = fetchIdFromOutput;
@@ -186,12 +183,6 @@ const fetchSourceCode = (contents, opts = {}) => {
186
183
  if (lineIndex === -1)
187
184
  lineIndex = lines.findIndex(l => l.includes(`${title}(`));
188
185
  }
189
- else if (opts.lang === 'csharp') {
190
- if (lineIndex === -1)
191
- lineIndex = lines.findIndex(l => l.includes(`public void ${title}`));
192
- if (lineIndex === -1)
193
- lineIndex = lines.findIndex(l => l.includes(`${title}(`));
194
- }
195
186
  else {
196
187
  lineIndex = lines.findIndex(l => l.includes(title));
197
188
  }
@@ -393,13 +384,6 @@ function formatStep(step, shift = 0) {
393
384
  }
394
385
  return lines;
395
386
  }
396
- function getPackageVersion() {
397
- const packageJsonPath = path_1.default.resolve(__dirname, '../../package.json');
398
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
399
- return packageJson.version;
400
- }
401
-
402
- module.exports.getPackageVersion = getPackageVersion;
403
387
 
404
388
  module.exports.formatStep = formatStep;
405
389
 
package/lib/xmlReader.js CHANGED
@@ -20,7 +20,7 @@ const uploader_js_1 = require("./uploader.js");
20
20
  const debug = (0, debug_1.default)('@testomatio/reporter:xml');
21
21
  const ridRunId = (0, crypto_1.randomUUID)();
22
22
  const TESTOMATIO_URL = process.env.TESTOMATIO_URL || 'https://app.testomat.io';
23
- const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_SUITE, TESTOMATIO_MAX_STACK_TRACE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } = process.env;
23
+ const { TESTOMATIO_RUNGROUP_TITLE, TESTOMATIO_TITLE, TESTOMATIO_ENV, TESTOMATIO_RUN, TESTOMATIO_MARK_DETACHED } = process.env;
24
24
  const options = {
25
25
  ignoreDeclaration: true,
26
26
  ignoreAttributes: false,
@@ -28,7 +28,6 @@ const options = {
28
28
  attributeNamePrefix: '',
29
29
  parseTagValue: true,
30
30
  };
31
- const MAX_OUTPUT_LENGTH = parseInt(TESTOMATIO_MAX_STACK_TRACE, 10) || 10000;
32
31
  const reduceOptions = {};
33
32
  class XmlReader {
34
33
  constructor(opts = {}) {
@@ -76,7 +75,7 @@ class XmlReader {
76
75
  /(<system-out><!\[CDATA\[)([\s\S]*?)(\]\]><\/system-out>)/g,
77
76
  ];
78
77
  for (const regex of cutRegexes) {
79
- xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, MAX_OUTPUT_LENGTH)}${p3}`);
78
+ xmlData = xmlData.replace(regex, (_, p1, p2, p3) => `${p1}${p2.substring(0, 5000)}${p3}`);
80
79
  }
81
80
  const jsonResult = this.parser.parse(xmlData);
82
81
  let jsonSuite;
@@ -314,8 +313,6 @@ class XmlReader {
314
313
  this.stats.language = 'js';
315
314
  if (file.endsWith('.ts'))
316
315
  this.stats.language = 'ts';
317
- if (file.endsWith('.cs'))
318
- this.stats.language = 'csharp';
319
316
  }
320
317
  if (!fs_1.default.existsSync(file)) {
321
318
  debug('Failed to open file with the source code', file);
@@ -362,13 +359,13 @@ class XmlReader {
362
359
  async uploadArtifacts() {
363
360
  for (const test of this.tests.filter(t => !!t.stack)) {
364
361
  let files = [];
365
- if (!test.files?.length)
366
- continue;
367
- files = test.files.map(f => path_1.default.isAbsolute(f) ? f : path_1.default.join(process.cwd(), f));
362
+ if (test.files?.length)
363
+ files = test.files.map(f => path_1.default.join(process.cwd(), f));
364
+ files = [...files, ...(0, utils_js_1.fetchFilesFromStackTrace)(test.stack)];
368
365
  if (!files.length)
369
366
  continue;
370
367
  const runId = this.runId || this.store.runId || Date.now().toString();
371
- test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId, path_1.default.basename(f)])));
368
+ test.artifacts = await Promise.all(files.map(f => this.uploader.uploadFileByPath(f, [runId])));
372
369
  console.log(constants_js_1.APP_PREFIX, `🗄️ Uploaded ${picocolors_1.default.bold(`${files.length} artifacts`)} for test ${test.title}`);
373
370
  }
374
371
  }
@@ -428,7 +425,7 @@ function reduceTestCases(prev, item) {
428
425
  testCases
429
426
  .filter(t => !!t)
430
427
  .forEach(testCaseItem => {
431
- const file = testCaseItem.file || item.filepath || item.fullname || '';
428
+ const file = testCaseItem.file || item.filepath || '';
432
429
  let stack = '';
433
430
  let message = '';
434
431
  if (testCaseItem.error)
@@ -461,34 +458,15 @@ function reduceTestCases(prev, item) {
461
458
  title = title.replace(/\(.*?\)/, '').trim();
462
459
  }
463
460
  stack = `${testCaseItem['system-out'] || testCaseItem.output || testCaseItem.log || ''}\n\n${stack}\n\n${suiteOutput}\n\n${suiteErr}`.trim();
464
- let testId = (0, utils_js_1.fetchIdFromOutput)(stack);
465
- if (tags?.length && !testId) {
466
- testId = tags.filter(t => t.startsWith('T')).map(t => `@${t}`).find(t => t.match(utils_js_1.TEST_ID_REGEX))?.slice(2);
467
- }
461
+ const testId = (0, utils_js_1.fetchIdFromOutput)(stack);
468
462
  let status = constants_js_1.STATUS.PASSED.toString();
469
463
  if ('failure' in testCaseItem || 'error' in testCaseItem)
470
464
  status = constants_js_1.STATUS.FAILED;
471
465
  if ('skipped' in testCaseItem)
472
466
  status = constants_js_1.STATUS.SKIPPED;
473
- if (testCaseItem.result && Object.values(constants_js_1.STATUS).includes(testCaseItem.result.toLowerCase())) {
474
- status = testCaseItem.result.toLowerCase();
475
- }
476
467
  let rid = null;
477
468
  if (testCaseItem.id)
478
469
  rid = `${ridRunId}-${testCaseItem.id}`;
479
- // Extract attachments
480
- let files = [];
481
- if (testCaseItem.attachments) {
482
- const attachments = Array.isArray(testCaseItem.attachments.attachment)
483
- ? testCaseItem.attachments.attachment
484
- : [testCaseItem.attachments.attachment];
485
- files = attachments
486
- .filter(a => a && a.filePath)
487
- .map(a => a.filePath);
488
- }
489
- // Extract files from stack trace using existing utility
490
- const stackFiles = (0, utils_js_1.fetchFilesFromStackTrace)(stack);
491
- files = [...new Set([...files, ...stackFiles])]; // Remove duplicates
492
470
  prev.push({
493
471
  rid,
494
472
  file,
@@ -503,9 +481,7 @@ function reduceTestCases(prev, item) {
503
481
  run_time: parseFloat(testCaseItem.time || testCaseItem.duration) * 1000,
504
482
  status,
505
483
  title,
506
- root_suite_id: TESTOMATIO_SUITE,
507
484
  suite_title: suiteTitle,
508
- files,
509
485
  });
510
486
  });
511
487
  return prev;
@@ -529,14 +505,11 @@ function fetchProperties(item) {
529
505
  let title = '';
530
506
  if (!item.properties)
531
507
  return {};
532
- // Handle both single property and array of properties
533
- const properties = Array.isArray(item.properties.property)
534
- ? item.properties.property
535
- : [item.properties.property].filter(Boolean);
536
- const prop = properties.find(p => p.name === 'Description');
508
+ const prop = [item.properties?.property].flat().find(p => p.name === 'Description');
537
509
  if (prop)
538
510
  title = prop.value;
539
- properties
511
+ [item.properties?.property]
512
+ .flat()
540
513
  .filter(p => p.name === 'Category')
541
514
  .forEach(p => tags.push(p.value));
542
515
  return { title, tags };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.0.0-beta.1-xml",
3
+ "version": "2.0.0-beta.2-gaxios",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -16,8 +16,7 @@
16
16
  "@cucumber/cucumber": "^10.9.0",
17
17
  "@octokit/rest": "^21.1.1",
18
18
  "aws-sdk": "^2.1072.0",
19
- "axios": "^1.6.2",
20
- "axios-retry": "^3.9.1",
19
+ "gaxios": "^6.0.0",
21
20
  "callsite-record": "^4.1.4",
22
21
  "commander": "^12",
23
22
  "cross-spawn": "^7.0.3",
@@ -49,6 +48,7 @@
49
48
  "testcafe"
50
49
  ],
51
50
  "scripts": {
51
+ "@cucumber/cucumber": "^10.9.0",
52
52
  "clear-exportdir": "rm -rf export/",
53
53
  "pretty": "npx prettier --check .",
54
54
  "pretty:fix": "prettier --write .",
@@ -67,9 +67,8 @@
67
67
  "test:adapter:playwright:example": "npx playwright test --config='./tests/adapter/examples/playwright/playwright.config.ts'",
68
68
  "test:adapter:vitest:example": "npx vitest --config='./tests/adapter/examples/vitest/vitest.config.ts'",
69
69
  "test:storage": "npx mocha tests-storage/artifact-storage.test.js && npx mocha tests-storage/data-storage.test.js && TESTOMATIO_INTERCEPT_CONSOLE_LOGS=true npx mocha tests-storage/logger.test.js && npx mocha tests-storage/logger-2.test.js && npx mocha tests-storage/reporter-functions.test.js",
70
- "build": "rm -rf ./cjs && tsc --module commonjs && npx tsx build/scripts/edit-js-files.js && npx tsx build/scripts/edit-package-json.js && chmod +x ./build/scripts/copy-tesmplate.sh && ./build/scripts/copy-tesmplate.sh",
71
- "build:bun": "rm -rf ./cjs && bun build ./src/reporter.js ./src/bin/reportXml.js ./src/bin/startTest.js ./src/bin/uploadArtifacts.js --outdir ./cjs --target node",
72
- "build:watch:bun": "rm -rf ./cjs && bun build ./src/bin/reportXml.js ./src/bin/startTest.js ./src/bin/uploadArtifacts.js --outdir ./cjs --target node --watch --onSuccess \"build/scripts/post-build.js\""
70
+ "//": "builds code from /src (esm) into /lib (commonjs)",
71
+ "build": "rm -rf ./cjs && tsc --module commonjs && npx tsx build/scripts/edit-js-files.js && npx tsx build/scripts/edit-package-json.js && chmod +x ./build/scripts/copy-tesmplate.sh && ./build/scripts/copy-tesmplate.sh"
73
72
  },
74
73
  "devDependencies": {
75
74
  "@playwright/test": "^1.49.1",
@@ -1,6 +1,6 @@
1
1
  import TestomatClient from '../client.js';
2
2
  import { config } from '../config.js';
3
- import { STATUS } from '../constants.js';
3
+ import { STATUS } from '../constants';
4
4
  import { getTestomatIdFromTestTitle } from '../utils/utils.js';
5
5
 
6
6
  const apiKey = config.TESTOMATIO;
@@ -1,4 +1,4 @@
1
- import { default as WDIOReporter, RunnerStats } from '@wdio/reporter';
1
+ import WDIOReporter, { RunnerStats } from '@wdio/reporter';
2
2
  import TestomatClient from '../client.js';
3
3
  import { getTestomatIdFromTestTitle, fileSystem } from '../utils/utils.js';
4
4
  import { services } from '../services/index.js';
package/src/bin/cli.js CHANGED
@@ -7,7 +7,7 @@ import createDebugMessages from 'debug';
7
7
  import TestomatClient from '../client.js';
8
8
  import XmlReader from '../xmlReader.js';
9
9
  import { APP_PREFIX, STATUS } from '../constants.js';
10
- import { getPackageVersion } from '../utils/utils.js';
10
+ import { version } from '../../package.json';
11
11
  import { config } from '../config.js';
12
12
  import { readLatestRunId } from '../utils/utils.js';
13
13
  import pc from 'picocolors';
@@ -15,7 +15,6 @@ import { filesize as prettyBytes } from 'filesize';
15
15
  import dotenv from 'dotenv';
16
16
 
17
17
  const debug = createDebugMessages('@testomatio/reporter:xml-cli');
18
- const version = getPackageVersion();
19
18
  console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
20
19
  const program = new Command();
21
20
 
@@ -5,11 +5,8 @@ import { glob } from 'glob';
5
5
  import createDebugMessages from 'debug';
6
6
  import { APP_PREFIX } from '../constants.js';
7
7
  import XmlReader from '../xmlReader.js';
8
- import { getPackageVersion } from '../utils/utils.js';
8
+ import { version } from '../../package.json';
9
9
  import dotenv from 'dotenv';
10
- import path from 'path';
11
-
12
- const version = getPackageVersion();
13
10
 
14
11
  const debug = createDebugMessages('@testomatio/reporter:xml-cli');
15
12
  console.log(pc.cyan(pc.bold(` 🤩 Testomat.io XML Reporter v${version}`)));
@@ -4,11 +4,10 @@ import { Command } from 'commander';
4
4
  import pc from 'picocolors';
5
5
  import TestomatClient from '../client.js';
6
6
  import { APP_PREFIX, STATUS } from '../constants.js';
7
- import { getPackageVersion } from '../utils/utils.js';
7
+ import { version } from '../../package.json';
8
8
  import { config } from '../config.js';
9
9
  import dotenv from 'dotenv';
10
10
 
11
- const version = getPackageVersion();
12
11
  console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
13
12
  const program = new Command();
14
13
 
@@ -5,13 +5,12 @@ import pc from 'picocolors';
5
5
  import createDebugMessages from 'debug';
6
6
  import TestomatClient from '../client.js';
7
7
  import { APP_PREFIX } from '../constants.js';
8
- import { getPackageVersion } from '../utils/utils.js';
8
+ import { version } from '../../package.json';
9
9
  import { config } from '../config.js';
10
10
  import { readLatestRunId } from '../utils/utils.js';
11
11
  import dotenv from 'dotenv';
12
12
 
13
13
  const debug = createDebugMessages('@testomatio/reporter:upload-cli');
14
- const version = getPackageVersion();
15
14
  console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
16
15
  const program = new Command();
17
16
 
@@ -1,4 +1,3 @@
1
- import path from 'path';
2
1
  import Adapter from './adapter.js';
3
2
 
4
3
  class CSharpAdapter extends Adapter {
@@ -8,21 +7,10 @@ class CSharpAdapter extends Adapter {
8
7
  if (example) t.example = { ...example[1].split(',') };
9
8
  const suite = t.suite_title.split('.');
10
9
  t.suite_title = suite.pop();
11
- t.file = namespaceToFileName(t.file);
10
+ t.file = suite.join('/');
12
11
  t.title = title.trim();
13
12
  return t;
14
13
  }
15
-
16
- getFilePath(t) {
17
- const fileName = namespaceToFileName(t.file);
18
- return fileName;
19
- }
20
14
  }
21
15
 
22
16
  export default CSharpAdapter;
23
-
24
- function namespaceToFileName(fileName) {
25
- const fileParts = fileName.split('.');
26
- fileParts[fileParts.length - 1] = fileParts[fileParts.length - 1]?.replace(/\$.*/, '');
27
- return `${fileParts.join(path.sep)}.cs`;
28
- }
@@ -1,7 +1,7 @@
1
1
  import { APP_PREFIX, testomatLogoURL } from '../constants.js';
2
2
  import { ansiRegExp, isSameTest } from '../utils/utils.js';
3
3
  import { statusEmoji, fullName } from '../utils/pipe_utils.js';
4
- import axios from 'axios';
4
+ import { Gaxios } from 'gaxios';
5
5
  import pc from 'picocolors';
6
6
  import humanizeDuration from 'humanize-duration';
7
7
  import merge from 'lodash.merge';
@@ -40,6 +40,13 @@ export class BitbucketPipe {
40
40
  }
41
41
 
42
42
  this.isEnabled = true;
43
+ this.client = new Gaxios({
44
+ baseURL: 'https://api.bitbucket.org/2.0',
45
+ headers: {
46
+ 'Content-Type': 'application/json',
47
+ 'Authorization': `Bearer ${this.token}`
48
+ }
49
+ });
43
50
 
44
51
  debug('Bitbucket Pipe: Enabled');
45
52
  }
@@ -166,26 +173,21 @@ export class BitbucketPipe {
166
173
 
167
174
  // Construct Bitbucket API URL for comments
168
175
  // eslint-disable-next-line max-len
169
- const commentsRequestURL = `https://api.bitbucket.org/2.0/repositories/${this.ENV.BITBUCKET_WORKSPACE}/${this.ENV.BITBUCKET_REPO_SLUG}/pullrequests/${this.ENV.BITBUCKET_PR_ID}/comments`;
176
+ const commentsRequestURL = `/repositories/${this.ENV.BITBUCKET_WORKSPACE}/${this.ENV.BITBUCKET_REPO_SLUG}/pullrequests/${this.ENV.BITBUCKET_PR_ID}/comments`;
170
177
 
171
178
  // Delete previous report
172
- await deletePreviousReport(axios, commentsRequestURL, this.hiddenCommentData, this.token);
179
+ await deletePreviousReport(this.client, commentsRequestURL, this.hiddenCommentData);
173
180
 
174
181
  // Add current report
175
182
  debug(`Adding comment via URL: ${commentsRequestURL}`);
176
183
  debug(`Final Bitbucket API call body: ${body}`);
177
184
 
178
185
  try {
179
- const addCommentResponse = await axios.post(
180
- commentsRequestURL,
181
- { content: { raw: body } },
182
- {
183
- headers: {
184
- Authorization: `Bearer ${this.token}`,
185
- 'Content-Type': 'application/json',
186
- },
187
- },
188
- );
186
+ const addCommentResponse = await this.client.request({
187
+ method: 'POST',
188
+ url: commentsRequestURL,
189
+ data: { content: { raw: body } }
190
+ });
189
191
 
190
192
  const commentID = addCommentResponse.data.id;
191
193
  // eslint-disable-next-line max-len
@@ -210,18 +212,16 @@ export class BitbucketPipe {
210
212
  updateRun() {}
211
213
  }
212
214
 
213
- async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCommentData, token) {
215
+ async function deletePreviousReport(client, commentsRequestURL, hiddenCommentData) {
214
216
  if (process.env.BITBUCKET_KEEP_OUTDATED_REPORTS) return;
215
217
 
216
218
  // Get comments
217
219
  let comments = [];
218
220
 
219
221
  try {
220
- const response = await axiosInstance.get(commentsRequestURL, {
221
- headers: {
222
- Authorization: `Bearer ${token}`,
223
- 'Content-Type': 'application/json',
224
- },
222
+ const response = await client.request({
223
+ method: 'GET',
224
+ url: commentsRequestURL
225
225
  });
226
226
  comments = response.data.values;
227
227
  } catch (e) {
@@ -236,11 +236,9 @@ async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCom
236
236
  try {
237
237
  // Delete previous comment
238
238
  const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
239
- await axiosInstance.delete(deleteCommentURL, {
240
- headers: {
241
- Authorization: `Bearer ${token}`,
242
- 'Content-Type': 'application/json',
243
- },
239
+ await client.request({
240
+ method: 'DELETE',
241
+ url: deleteCommentURL
244
242
  });
245
243
  } catch (e) {
246
244
  console.warn(`Can't delete previously added comment with testomat.io report. Ignored.`);
@@ -1,5 +1,5 @@
1
1
  import createDebugMessages from 'debug';
2
- import axios from 'axios';
2
+ import { Gaxios } from 'gaxios';
3
3
  import pc from 'picocolors';
4
4
  import humanizeDuration from 'humanize-duration';
5
5
  import merge from 'lodash.merge';
@@ -45,6 +45,12 @@ class GitLabPipe {
45
45
  }
46
46
 
47
47
  this.isEnabled = true;
48
+ this.client = new Gaxios({
49
+ baseURL: 'https://gitlab.com/api/v4',
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ }
53
+ });
48
54
 
49
55
  debug('GitLab Pipe: Enabled');
50
56
  }
@@ -157,16 +163,21 @@ class GitLabPipe {
157
163
  }
158
164
 
159
165
  // eslint-disable-next-line max-len
160
- const commentsRequestURL = `https://gitlab.com/api/v4/projects/${this.ENV.CI_PROJECT_ID}/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}/notes`;
166
+ const commentsRequestURL = `/projects/${this.ENV.CI_PROJECT_ID}/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}/notes`;
161
167
 
162
168
  // delete previous report
163
- await deletePreviousReport(axios, commentsRequestURL, this.hiddenCommentData, this.token);
169
+ await deletePreviousReport(this.client, commentsRequestURL, this.hiddenCommentData, this.token);
164
170
 
165
171
  // add current report
166
172
  debug(`Adding comment via url: ${commentsRequestURL}`);
167
173
 
168
174
  try {
169
- const addCommentResponse = await axios.post(`${commentsRequestURL}?access_token=${this.token}`, { body });
175
+ const addCommentResponse = await this.client.request({
176
+ method: 'POST',
177
+ url: commentsRequestURL,
178
+ params: { access_token: this.token },
179
+ data: { body }
180
+ });
170
181
 
171
182
  const commentID = addCommentResponse.data.id;
172
183
  // eslint-disable-next-line max-len
@@ -191,14 +202,18 @@ class GitLabPipe {
191
202
  updateRun() {}
192
203
  }
193
204
 
194
- async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCommentData, token) {
205
+ async function deletePreviousReport(client, commentsRequestURL, hiddenCommentData, token) {
195
206
  if (process.env.GITLAB_KEEP_OUTDATED_REPORTS) return;
196
207
 
197
208
  // get comments
198
209
  let comments = [];
199
210
 
200
211
  try {
201
- const response = await axiosInstance.get(`${commentsRequestURL}?access_token=${token}`);
212
+ const response = await client.request({
213
+ method: 'GET',
214
+ url: commentsRequestURL,
215
+ params: { access_token: token }
216
+ });
202
217
  comments = response.data;
203
218
  } catch (e) {
204
219
  console.error('Error while attempt to retrieve comments on GitLab Merge Request:\n', e);
@@ -211,8 +226,12 @@ async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCom
211
226
  if (comment.body.includes(hiddenCommentData)) {
212
227
  try {
213
228
  // delete previous comment
214
- const deleteCommentURL = `${commentsRequestURL}/${comment.id}?access_token=${token}`;
215
- await axiosInstance.delete(deleteCommentURL);
229
+ const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
230
+ await client.request({
231
+ method: 'DELETE',
232
+ url: deleteCommentURL,
233
+ params: { access_token: token }
234
+ });
216
235
  } catch (e) {
217
236
  console.warn(`Can't delete previously added comment with testomat.io report. Ignore.`);
218
237
  }