@testomatio/reporter 2.3.7-beta.11-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.11-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
- let 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,39 +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 && fullLogs?.trim()?.length > 0) {
214
- uploadedFiles.push(
215
- this.uploader.uploadFileAsBuffer(
216
- Buffer.from(stripColors(fullLogs), 'utf8'),
217
- [this.runId, rid, `logs_${+new Date}.log`]
218
- )
219
- );
220
- fullLogs = '';
221
- steps = null;
222
- }
223
-
224
-
225
- if (!this.pipes || !this.pipes.length)
226
- this.pipes = await pipesFactory(this.paramsForPipesFactory || {}, this.pipeStore);
227
-
228
- if (!this.pipes?.filter(p => p.isEnabled).length) {
229
- if (uploadedFiles.length > 0) {
230
- await Promise.all(uploadedFiles);
231
- }
232
- return [];
233
- }
234
-
235
- if (isTestShouldBeExculedFromReport(testData)) return [];
236
-
237
- if (status === STATUS.SKIPPED && process.env.TESTOMATIO_EXCLUDE_SKIPPED) {
238
- debug('Skipping test from report', testData?.title);
239
- return [];
240
- }
208
+ // Attach logs
209
+ const fullLogs = this.formatLogs({ error: errorFormatted, steps, logs: testData.logs });
241
210
 
211
+ // add artifacts
242
212
  if (manuallyAttachedArtifacts?.length) files.push(...manuallyAttachedArtifacts);
243
213
 
214
+ const uploadedFiles = [];
215
+
244
216
  for (let f of files) {
245
217
  if (!f) continue; // f === null
246
218
  if (typeof f === 'object') {
@@ -336,7 +308,7 @@ class Client {
336
308
  const uploadedArtifacts = this.uploader.successfulUploads.map(file => ({
337
309
  relativePath: file.path.replace(process.cwd(), ''),
338
310
  link: file.link,
339
- sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
311
+ sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
340
312
  }));
341
313
 
342
314
  uploadedArtifacts.forEach(upload => {
@@ -358,7 +330,7 @@ class Client {
358
330
  );
359
331
  const failedUploads = this.uploader.failedUploads.map(file => ({
360
332
  relativePath: file.path.replace(process.cwd(), ''),
361
- sizePretty: file.size == null ? 'unknown' : prettyBytes(file.size, { round: 0 }).toString(),
333
+ sizePretty: prettyBytes(file.size, { round: 0 }).toString(),
362
334
  }));
363
335
 
364
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
  };