@testomatio/reporter 2.3.7-beta.4-stack-artifacts → 2.3.7-beta.5-stack-artifacts

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.
@@ -35,7 +35,7 @@ while (i < args.length) {
35
35
  newArgs[0] = 'start';
36
36
  }
37
37
  else if (arg === '--finish') {
38
- // Map --finish to finish command
38
+ // Map --finish to finish command
39
39
  newArgs[0] = 'finish';
40
40
  }
41
41
  else {
@@ -46,8 +46,8 @@ while (i < args.length) {
46
46
  }
47
47
  // Execute the main CLI with mapped arguments
48
48
  const child = (0, node_child_process_1.spawn)(process.execPath, [cliPath, ...newArgs], {
49
- stdio: 'inherit'
49
+ stdio: 'inherit',
50
50
  });
51
- child.on('exit', (code) => {
51
+ child.on('exit', code => {
52
52
  process.exit(code);
53
53
  });
package/lib/client.js CHANGED
@@ -158,6 +158,17 @@ class Client {
158
158
  * @returns {Promise<PipeResult[]>}
159
159
  */
160
160
  async addTestRun(status, testData) {
161
+ if (!this.pipes || !this.pipes.length)
162
+ this.pipes = await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
163
+ // all pipes disabled, skipping
164
+ if (!this.pipes?.filter(p => p.isEnabled).length)
165
+ return [];
166
+ if (isTestShouldBeExculedFromReport(testData))
167
+ return [];
168
+ if (status === constants_js_1.STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
169
+ debug('Skipping test from report', testData?.title);
170
+ return []; // do not log skipped tests
171
+ }
161
172
  if (!testData)
162
173
  testData = {
163
174
  title: 'Unknown test',
@@ -170,37 +181,9 @@ class Client {
170
181
  /**
171
182
  * @type {TestData}
172
183
  */
173
- const { rid, error = null, steps: originalSteps, title, suite_title, } = testData;
174
- let steps = originalSteps;
175
- const uploadedFiles = [];
176
- const stackArtifactsEnabled = (0, utils_js_1.transformEnvVarToBoolean)(process.env.TESTOMATIO_STACK_ARTIFACTS);
177
- let formattedSteps;
178
- if (stackArtifactsEnabled) {
179
- const timestamp = +new Date;
180
- formattedSteps = Array.isArray(steps) ? steps.map(step => (0, utils_js_1.formatStep)(step)).flat().join('\n') : '';
181
- if (error?.stack?.length > 5000) {
182
- uploadedFiles.push(this.uploader.uploadFileAsBuffer(Buffer.from(error.stack, 'utf8'), [this.runId, rid, `stack_${timestamp}.log`]));
183
- }
184
- if (formattedSteps?.length > 10000) {
185
- uploadedFiles.push(this.uploader.uploadFileAsBuffer(Buffer.from(JSON.stringify(steps, null, 2), 'utf8'), [this.runId, rid, `steps_${timestamp}.json`]));
186
- }
187
- }
188
- if (!this.pipes || !this.pipes.length)
189
- this.pipes = await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
190
- if (!this.pipes?.filter(p => p.isEnabled).length) {
191
- if (uploadedFiles.length > 0) {
192
- await Promise.all(uploadedFiles);
193
- }
194
- return [];
195
- }
196
- if (isTestShouldBeExculedFromReport(testData))
197
- return [];
198
- if (status === constants_js_1.STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
199
- debug('Skipping test from report', testData?.title);
200
- return [];
201
- }
202
- const { time = 0, example = null, files = [], filesBuffers = [], code = null, file, suite_id, test_id, timestamp, links, manuallyAttachedArtifacts, overwrite, tags, } = testData;
184
+ const { rid, error = null, time = 0, example = null, files = [], filesBuffers = [], steps, code = null, title, file, suite_title, suite_id, test_id, timestamp, links, manuallyAttachedArtifacts, overwrite, tags, } = testData;
203
185
  let { message = '', meta = {} } = testData;
186
+ // stringify meta values and limit keys and values length to 255
204
187
  meta = Object.entries(meta)
205
188
  .filter(([, value]) => value !== null && value !== undefined)
206
189
  .reduce((acc, [key, value]) => {
@@ -208,29 +191,19 @@ class Client {
208
191
  acc[key] = value;
209
192
  return acc;
210
193
  }, {});
194
+ // Get links from storage using the test context
211
195
  const testContext = suite_title ? `${suite_title} ${title}` : title;
212
196
  let errorFormatted = '';
213
197
  if (error) {
214
198
  errorFormatted += this.formatError(error) || '';
215
199
  message = error?.message;
216
200
  }
217
- if (stackArtifactsEnabled) {
218
- if (error?.stack?.length > 5000)
219
- errorFormatted = `[Large stack saved as artifact]`;
220
- if (formattedSteps?.length > 10000)
221
- steps = null;
222
- }
223
- else {
224
- formattedSteps = Array.isArray(steps) ? steps.map(step => (0, utils_js_1.formatStep)(step)).flat().join('\n') : '';
225
- }
226
- let fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
227
- if (stackArtifactsEnabled && fullLogs.length > 5000) {
228
- const timestamp = +new Date;
229
- uploadedFiles.push(this.uploader.uploadFileAsBuffer(Buffer.from(fullLogs, 'utf8'), [this.runId, rid, `logs_${timestamp}.log`]));
230
- fullLogs = fullLogs.slice(0, 5000) + '\n\n[Full logs saved as artifact]';
231
- }
201
+ // Attach logs
202
+ const fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
203
+ // add artifacts
232
204
  if (manuallyAttachedArtifacts?.length)
233
205
  files.push(...manuallyAttachedArtifacts);
206
+ const uploadedFiles = [];
234
207
  for (let f of files) {
235
208
  if (!f)
236
209
  continue; // f === null
@@ -420,7 +420,7 @@ class TestomatioPipe {
420
420
  if (this.runUrl && this.proceed) {
421
421
  const notFinishedMessage = picocolors_1.default.yellow(picocolors_1.default.bold('Run was not finished because of $TESTOMATIO_PROCEED'));
422
422
  console.log(constants_js_1.APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${picocolors_1.default.magenta(this.runUrl)}`);
423
- console.log(constants_js_1.APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
423
+ console.log(constants_js_1.APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx @testomatio/reporter finish`);
424
424
  }
425
425
  if (this.hasUnmatchedTests) {
426
426
  console.log('');
package/lib/reporter.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- export { Client };
2
- export const STATUS: {
3
- PASSED: string;
4
- FAILED: string;
5
- SKIPPED: string;
6
- FINISHED: string;
7
- };
8
1
  export const artifact: (data: string | {
9
2
  path: string;
10
3
  type: string;
@@ -87,7 +80,7 @@ export const label: (key: string, value?: string | null) => void;
87
80
  export const linkTest: (...testIds: string[]) => void;
88
81
  export const linkJira: (...jiraIds: string[]) => void;
89
82
  declare namespace _default {
90
- export let testomatioLogger: {
83
+ let testomatioLogger: {
91
84
  "__#13@#originalUserLogger": {
92
85
  assert(condition?: boolean, ...data: any[]): void;
93
86
  assert(value: any, message?: string, ...optionalParams: any[]): void;
@@ -155,13 +148,13 @@ declare namespace _default {
155
148
  }): void;
156
149
  prettyObjects: boolean;
157
150
  };
158
- export let artifact: (data: string | {
151
+ let artifact: (data: string | {
159
152
  path: string;
160
153
  type: string;
161
154
  name: string;
162
155
  }, context?: any) => void;
163
- export let log: (...args: any[]) => void;
164
- export let logger: {
156
+ let log: (...args: any[]) => void;
157
+ let logger: {
165
158
  "__#13@#originalUserLogger": {
166
159
  assert(condition?: boolean, ...data: any[]): void;
167
160
  assert(value: any, message?: string, ...optionalParams: any[]): void;
@@ -229,15 +222,13 @@ declare namespace _default {
229
222
  }): void;
230
223
  prettyObjects: boolean;
231
224
  };
232
- export let meta: (keyValue: {
225
+ let meta: (keyValue: {
233
226
  [key: string]: string;
234
227
  } | string, value?: string | null) => void;
235
- export let step: (message: string) => void;
236
- export let label: (key: string, value?: string | null) => void;
237
- export let linkTest: (...testIds: string[]) => void;
238
- export let linkJira: (...jiraIds: string[]) => void;
239
- export { Client as TestomatioClient };
240
- export { STATUS };
228
+ let step: (message: string) => void;
229
+ let label: (key: string, value?: string | null) => void;
230
+ let linkTest: (...testIds: string[]) => void;
231
+ let linkJira: (...jiraIds: string[]) => void;
241
232
  }
242
233
  export default _default;
243
234
  export type ArtifactFunction = typeof import("./reporter-functions.js").default.artifact;
@@ -246,4 +237,3 @@ export type LoggerService = typeof import("./services/index.js").services.logger
246
237
  export type MetaFunction = typeof import("./reporter-functions.js").default.keyValue;
247
238
  export type StepFunction = typeof import("./reporter-functions.js").default.step;
248
239
  export type LabelFunction = typeof import("./reporter-functions.js").default.label;
249
- import Client from './client.js';
package/lib/reporter.js CHANGED
@@ -1,48 +1,13 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.linkJira = exports.linkTest = exports.label = exports.step = exports.meta = exports.logger = exports.log = exports.artifact = exports.STATUS = exports.Client = void 0;
40
- const client_js_1 = __importDefault(require("./client.js"));
41
- exports.Client = client_js_1.default;
42
- const TestomatioConstants = __importStar(require("./constants.js"));
6
+ exports.linkJira = exports.linkTest = exports.label = exports.step = exports.meta = exports.logger = exports.log = exports.artifact = void 0;
7
+ // import TestomatClient from './client.js';
8
+ // import * as TRConstants from './constants.js';
43
9
  const index_js_1 = require("./services/index.js");
44
10
  const reporter_functions_js_1 = __importDefault(require("./reporter-functions.js"));
45
- exports.STATUS = TestomatioConstants.STATUS;
46
11
  exports.artifact = reporter_functions_js_1.default.artifact;
47
12
  exports.log = reporter_functions_js_1.default.log;
48
13
  exports.logger = index_js_1.services.logger;
@@ -72,6 +37,6 @@ module.exports = {
72
37
  label: reporter_functions_js_1.default.label,
73
38
  linkTest: reporter_functions_js_1.default.linkTest,
74
39
  linkJira: reporter_functions_js_1.default.linkJira,
75
- TestomatioClient: client_js_1.default,
76
- STATUS: exports.STATUS,
40
+ // TestomatClient,
41
+ // TRConstants,
77
42
  };