@testomatio/reporter 2.3.7-beta.10-stack-artifacts → 2.3.7-beta.11-fix-vite

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.
@@ -471,14 +471,10 @@ function transformEnvVarToBoolean(value) {
471
471
  return Boolean(value);
472
472
  }
473
473
  function truncate(s, size = 255) {
474
- if (s === undefined || s === null) {
475
- return '';
476
- }
477
- const str = s.toString();
478
- if (str.trim().length < size) {
479
- return str;
474
+ if (s.toString().trim().length < size) {
475
+ return s.toString();
480
476
  }
481
- return `${str.substring(0, size)}...`;
477
+ return `${s.toString().substring(0, size)}...`;
482
478
  }
483
479
 
484
480
  module.exports.getPackageVersion = getPackageVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "2.3.7-beta.10-stack-artifacts",
3
+ "version": "2.3.7-beta.11-fix-vite",
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,21 +10,11 @@ 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
- import { stripVTControlCharacters } from 'util';
23
15
 
24
16
  const debug = createDebugMessages('@testomatio/reporter:client');
25
17
 
26
- const stripColors = stripVTControlCharacters || ((str) => str?.replace(/\x1b\[[0-9;]*m/g, '') || '');
27
-
28
18
  // removed __dirname usage, because:
29
19
  // 1. replaced with ESM syntax (import.meta.url), but it throws an error on tsc compilation;
30
20
  // 2. got error "__dirname already defined" in compiles js code (cjs dir)
@@ -149,6 +139,19 @@ class Client {
149
139
  * @returns {Promise<PipeResult[]>}
150
140
  */
151
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
+
152
155
  if (!testData)
153
156
  testData = {
154
157
  title: 'Unknown test',
@@ -166,23 +169,15 @@ class Client {
166
169
  const {
167
170
  rid,
168
171
  error = null,
169
- steps: originalSteps,
170
- title,
171
- suite_title,
172
- } = testData;
173
- const steps = originalSteps;
174
-
175
- const uploadedFiles = [];
176
- const stackArtifactsEnabled = transformEnvVarToBoolean(process.env.TESTOMATIO_STACK_ARTIFACTS);
177
-
178
-
179
- const {
180
172
  time = 0,
181
173
  example = null,
182
174
  files = [],
183
175
  filesBuffers = [],
176
+ steps,
184
177
  code = null,
178
+ title,
185
179
  file,
180
+ suite_title,
186
181
  suite_id,
187
182
  test_id,
188
183
  timestamp,
@@ -193,6 +188,7 @@ class Client {
193
188
  } = testData;
194
189
  let { message = '', meta = {} } = testData;
195
190
 
191
+ // stringify meta values and limit keys and values length to 255
196
192
  meta = Object.entries(meta)
197
193
  .filter(([, value]) => value !== null && value !== undefined)
198
194
  .reduce((acc, [key, value]) => {
@@ -200,6 +196,7 @@ class Client {
200
196
  return acc;
201
197
  }, {});
202
198
 
199
+ // Get links from storage using the test context
203
200
  const testContext = suite_title ? `${suite_title} ${title}` : title;
204
201
 
205
202
  let errorFormatted = '';
@@ -208,41 +205,14 @@ class Client {
208
205
  message = error?.message;
209
206
  }
210
207
 
211
- let fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
212
-
213
- if (stackArtifactsEnabled && status && (steps || testData.logs || error)) {
214
- const timestamp = +new Date;
215
- if (fullLogs && fullLogs.trim().length > 0) {
216
- uploadedFiles.push(
217
- this.uploader.uploadFileAsBuffer(
218
- Buffer.from(stripColors(fullLogs), 'utf8'),
219
- [this.runId, rid, `logs_${timestamp}.txt`]
220
- )
221
- );
222
- }
223
- fullLogs = '';
224
- }
225
-
226
-
227
- if (!this.pipes || !this.pipes.length)
228
- this.pipes = await pipesFactory(this.paramsForPipesFactory || {}, this.pipeStore);
229
-
230
- if (!this.pipes?.filter(p => p.isEnabled).length) {
231
- if (uploadedFiles.length > 0) {
232
- await Promise.all(uploadedFiles);
233
- }
234
- return [];
235
- }
236
-
237
- if (isTestShouldBeExculedFromReport(testData)) return [];
238
-
239
- if (status === STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
240
- debug('Skipping test from report', testData?.title);
241
- return [];
242
- }
208
+ // Attach logs
209
+ const fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
243
210
 
211
+ // add artifacts
244
212
  if (manuallyAttachedArtifacts?.length) files.push(...manuallyAttachedArtifacts);
245
213
 
214
+ const uploadedFiles = [];
215
+
246
216
  for (let f of files) {
247
217
  if (!f) continue; // f === null
248
218
  if (typeof f === 'object') {
@@ -338,7 +308,7 @@ class Client {
338
308
  const uploadedArtifacts = this.uploader.successfulUploads.map(file => ({
339
309
  relativePath: file.path.replace(process.cwd(), ''),
340
310
  link: file.link,
341
- sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
311
+ sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
342
312
  }));
343
313
 
344
314
  uploadedArtifacts.forEach(upload => {
@@ -360,7 +330,7 @@ class Client {
360
330
  );
361
331
  const failedUploads = this.uploader.failedUploads.map(file => ({
362
332
  relativePath: file.path.replace(process.cwd(), ''),
363
- sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
333
+ sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
364
334
  }));
365
335
 
366
336
  const pathPadding = Math.max(...failedUploads.map(upload => upload.relativePath.length)) + 1;
@@ -170,7 +170,7 @@ class TestomatioPipe {
170
170
  this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
171
171
  if (!this.isEnabled) return;
172
172
  if (this.batch.isEnabled && this.isEnabled)
173
- this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
173
+ this.batch.intervalFunction = setInterval(() => this.#batchUpload(), this.batch.intervalTime);
174
174
 
175
175
  let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
176
176
 
@@ -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
  };