@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.3.7-beta.4-stack-artifacts",
3
+ "version": "2.3.7-beta.5-stack-artifacts",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -18,7 +18,7 @@ const newArgs = ['run'];
18
18
  let i = 0;
19
19
  while (i < args.length) {
20
20
  const arg = args[i];
21
-
21
+
22
22
  if (arg === '-c' || arg === '--command') {
23
23
  // Map -c/--command to positional argument for run command
24
24
  i++;
@@ -33,7 +33,7 @@ while (i < args.length) {
33
33
  // Map --launch to start command
34
34
  newArgs[0] = 'start';
35
35
  } else if (arg === '--finish') {
36
- // Map --finish to finish command
36
+ // Map --finish to finish command
37
37
  newArgs[0] = 'finish';
38
38
  } else {
39
39
  // Pass through other arguments
@@ -45,9 +45,9 @@ while (i < args.length) {
45
45
  // Execute the main CLI with mapped arguments
46
46
 
47
47
  const child = spawn(process.execPath, [cliPath, ...newArgs], {
48
- stdio: 'inherit'
48
+ stdio: 'inherit',
49
49
  });
50
50
 
51
- child.on('exit', (code) => {
51
+ child.on('exit', code => {
52
52
  process.exit(code);
53
- });
53
+ });
package/src/client.js CHANGED
@@ -10,14 +10,7 @@ import { glob } from 'glob';
10
10
  import path, { sep } from 'path';
11
11
  import { fileURLToPath } from 'node:url';
12
12
  import { S3Uploader } from './uploader.js';
13
- import {
14
- formatStep,
15
- truncate,
16
- readLatestRunId,
17
- storeRunId,
18
- validateSuiteId,
19
- transformEnvVarToBoolean
20
- } from './utils/utils.js';
13
+ import { formatStep, truncate, readLatestRunId, storeRunId, validateSuiteId } from './utils/utils.js';
21
14
  import { filesize as prettyBytes } from 'filesize';
22
15
 
23
16
  const debug = createDebugMessages('@testomatio/reporter:client');
@@ -146,6 +139,19 @@ class Client {
146
139
  * @returns {Promise<PipeResult[]>}
147
140
  */
148
141
  async addTestRun(status, testData) {
142
+ if (!this.pipes || !this.pipes.length)
143
+ this.pipes = await pipesFactory(this.paramsForPipesFactory || {}, this.pipeStore);
144
+
145
+ // all pipes disabled, skipping
146
+ if (!this.pipes?.filter(p => p.isEnabled).length) return [];
147
+
148
+ if (isTestShouldBeExculedFromReport(testData)) return [];
149
+
150
+ if (status === STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
151
+ debug('Skipping test from report', testData?.title);
152
+ return []; // do not log skipped tests
153
+ }
154
+
149
155
  if (!testData)
150
156
  testData = {
151
157
  title: 'Unknown test',
@@ -163,61 +169,15 @@ class Client {
163
169
  const {
164
170
  rid,
165
171
  error = null,
166
- steps: originalSteps,
167
- title,
168
- suite_title,
169
- } = testData;
170
- let steps = originalSteps;
171
-
172
- const uploadedFiles = [];
173
- const stackArtifactsEnabled = transformEnvVarToBoolean(process.env.TESTOMATIO_STACK_ARTIFACTS);
174
-
175
- let formattedSteps;
176
- if (stackArtifactsEnabled) {
177
- const timestamp = +new Date;
178
- formattedSteps = Array.isArray(steps) ? steps.map(step => formatStep(step)).flat().join('\n') : '';
179
-
180
- if (error?.stack?.length > 5000) {
181
- uploadedFiles.push(
182
- this.uploader.uploadFileAsBuffer(
183
- Buffer.from(error.stack, 'utf8'),
184
- [this.runId, rid, `stack_${timestamp}.log`]
185
- )
186
- );
187
- }
188
- if (formattedSteps?.length > 10000) {
189
- uploadedFiles.push(
190
- this.uploader.uploadFileAsBuffer(
191
- Buffer.from(JSON.stringify(steps, null, 2), 'utf8'),
192
- [this.runId, rid, `steps_${timestamp}.json`]
193
- )
194
- );
195
- }
196
- }
197
- if (!this.pipes || !this.pipes.length)
198
- this.pipes = await pipesFactory(this.paramsForPipesFactory || {}, this.pipeStore);
199
-
200
- if (!this.pipes?.filter(p => p.isEnabled).length) {
201
- if (uploadedFiles.length > 0) {
202
- await Promise.all(uploadedFiles);
203
- }
204
- return [];
205
- }
206
-
207
- if (isTestShouldBeExculedFromReport(testData)) return [];
208
-
209
- if (status === STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
210
- debug('Skipping test from report', testData?.title);
211
- return [];
212
- }
213
-
214
- const {
215
172
  time = 0,
216
173
  example = null,
217
174
  files = [],
218
175
  filesBuffers = [],
176
+ steps,
219
177
  code = null,
178
+ title,
220
179
  file,
180
+ suite_title,
221
181
  suite_id,
222
182
  test_id,
223
183
  timestamp,
@@ -228,6 +188,7 @@ class Client {
228
188
  } = testData;
229
189
  let { message = '', meta = {} } = testData;
230
190
 
191
+ // stringify meta values and limit keys and values length to 255
231
192
  meta = Object.entries(meta)
232
193
  .filter(([, value]) => value !== null && value !== undefined)
233
194
  .reduce((acc, [key, value]) => {
@@ -235,6 +196,7 @@ class Client {
235
196
  return acc;
236
197
  }, {});
237
198
 
199
+ // Get links from storage using the test context
238
200
  const testContext = suite_title ? `${suite_title} ${title}` : title;
239
201
 
240
202
  let errorFormatted = '';
@@ -243,28 +205,14 @@ class Client {
243
205
  message = error?.message;
244
206
  }
245
207
 
246
- if (stackArtifactsEnabled) {
247
- if (error?.stack?.length > 5000) errorFormatted = `[Large stack saved as artifact]`;
248
- if (formattedSteps?.length > 10000) steps = null;
249
- } else {
250
- formattedSteps = Array.isArray(steps) ? steps.map(step => formatStep(step)).flat().join('\n') : '';
251
- }
252
-
253
- let fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
254
-
255
- if (stackArtifactsEnabled && fullLogs.length > 5000) {
256
- const timestamp = +new Date;
257
- uploadedFiles.push(
258
- this.uploader.uploadFileAsBuffer(
259
- Buffer.from(fullLogs, 'utf8'),
260
- [this.runId, rid, `logs_${timestamp}.log`]
261
- )
262
- );
263
- fullLogs = fullLogs.slice(0, 5000) + '\n\n[Full logs saved as artifact]';
264
- }
208
+ // Attach logs
209
+ const fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
265
210
 
211
+ // add artifacts
266
212
  if (manuallyAttachedArtifacts?.length) files.push(...manuallyAttachedArtifacts);
267
213
 
214
+ const uploadedFiles = [];
215
+
268
216
  for (let f of files) {
269
217
  if (!f) continue; // f === null
270
218
  if (typeof f === 'object') {
@@ -472,7 +472,7 @@ class TestomatioPipe {
472
472
  if (this.runUrl && this.proceed) {
473
473
  const notFinishedMessage = pc.yellow(pc.bold('Run was not finished because of $TESTOMATIO_PROCEED'));
474
474
  console.log(APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${pc.magenta(this.runUrl)}`);
475
- console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
475
+ console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx @testomatio/reporter finish`);
476
476
  }
477
477
 
478
478
  if (this.hasUnmatchedTests) {
package/src/reporter.js CHANGED
@@ -1,10 +1,8 @@
1
- import Client from './client.js';
2
- import * as TestomatioConstants from './constants.js';
1
+ // import TestomatClient from './client.js';
2
+ // import * as TRConstants from './constants.js';
3
3
  import { services } from './services/index.js';
4
4
  import reporterFunctions from './reporter-functions.js';
5
5
 
6
- export { Client };
7
- export const STATUS = TestomatioConstants.STATUS;
8
6
  export const artifact = reporterFunctions.artifact;
9
7
  export const log = reporterFunctions.log;
10
8
  export const logger = services.logger;
@@ -37,7 +35,6 @@ export default {
37
35
  linkTest: reporterFunctions.linkTest,
38
36
  linkJira: reporterFunctions.linkJira,
39
37
 
40
- TestomatioClient: Client,
41
- STATUS,
42
-
38
+ // TestomatClient,
39
+ // TRConstants,
43
40
  };