@testomatio/reporter 1.6.0-beta-3-artifacts → 1.6.0-beta-5-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/lib/bin/cli.js CHANGED
@@ -172,15 +172,16 @@ program
172
172
  const apiKey = config.TESTOMATIO;
173
173
 
174
174
  process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
175
- process.env.TESTOMATIO_RUN ||= readLatestRunId();
175
+ const runId = process.env.TESTOMATIO_RUN || process.env.runId || readLatestRunId();
176
176
 
177
- if (!process.env.TESTOMATIO_RUN) {
177
+ if (!runId) {
178
178
  console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
179
179
  return process.exit(1);
180
180
  }
181
181
 
182
182
  const client = new TestomatClient({
183
183
  apiKey,
184
+ runId,
184
185
  isBatchEnabled: false,
185
186
  });
186
187
 
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- const program = require('commander');
2
+ const { program } = require('commander');
3
3
  const chalk = require('chalk');
4
4
  const debug = require('debug')('@testomatio/reporter:upload-cli');
5
5
  const TestomatClient = require('../client');
6
6
  const { APP_PREFIX } = require('../constants');
7
7
  const { version } = require('../../package.json');
8
8
  const config = require('../config');
9
+ const { readLatestRunId } = require('../utils/utils');
9
10
 
10
11
  console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
11
12
 
@@ -21,15 +22,19 @@ program
21
22
  }
22
23
 
23
24
  const apiKey = config.TESTOMATIO;
24
-
25
25
  process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
26
- // process.env.TESTOMATIO_ARTIFACTS_SIZE = null;
26
+ const runId = process.env.TESTOMATIO_RUN || process.env.runId || readLatestRunId();
27
+
28
+ if (!runId) {
29
+ console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
30
+ return process.exit(1);
31
+ }
27
32
 
28
33
  const client = new TestomatClient({
29
34
  apiKey,
35
+ runId,
30
36
  isBatchEnabled: false,
31
37
  });
32
-
33
38
  let testruns = client.uploader.readUploadedFiles(process.env.TESTOMATIO_RUN);
34
39
 
35
40
  const numTotalArtifacts = testruns.length;
package/lib/client.js CHANGED
@@ -263,7 +263,11 @@ class Client {
263
263
  }
264
264
 
265
265
  if (this.uploader.failedUploadsCount) {
266
- console.log(APP_PREFIX, `${this.uploader.failedUploadsCount} artifacts failed to upload`);
266
+ console.log(
267
+ APP_PREFIX,
268
+ chalk.gray('[CLIENT]'),
269
+ `${this.uploader.failedUploadsCount} artifacts failed to upload`,
270
+ );
267
271
  }
268
272
 
269
273
  if (this.uploader.isEnabled && this.uploader.skippedUploadsCount) {
@@ -271,7 +275,7 @@ class Client {
271
275
  }
272
276
 
273
277
  if (this.uploader.skippedUploadsCount || this.uploader.failedUploadsCount) {
274
- const command = `TESTOMATIO_RUN=${this.runId} npx upload-artifacts`;
278
+ const command = `TESTOMATIO_RUN=${this.runId} npx @testomatio/reporter upload-artifacts`;
275
279
  console.log(
276
280
  APP_PREFIX,
277
281
  `Run "${chalk.magenta(command)}" with valid S3 credentials to upload skipped & failed artifacts`,
package/lib/uploader.js CHANGED
@@ -129,14 +129,19 @@ class S3Uploader {
129
129
  }
130
130
 
131
131
  const stats = fs.statSync(tempFilePath);
132
+ debug('Artifacts file stats:', +stats.mtime);
133
+ debug('Current time:', +new Date());
132
134
  const diff = +new Date() - +stats.mtime;
135
+ debug('Diff:', diff);
133
136
  const diffHours = diff / 1000 / 60 / 60;
137
+ debug('Diff hours:', diffHours);
134
138
  if (diffHours > 3) {
135
139
  console.log(APP_PREFIX, "Artifacts file is too old, can't process artifacts. Please re-run the tests.");
136
140
  return [];
137
141
  }
138
142
 
139
143
  const data = fs.readFileSync(tempFilePath, 'utf8');
144
+ debug('Artifacts file contents:', data);
140
145
  const lines = data.split('\n').filter(Boolean);
141
146
  return lines.map(line => JSON.parse(line));
142
147
  }
@@ -157,6 +162,10 @@ class S3Uploader {
157
162
 
158
163
  const tempFilePath = this.#getUploadFilePath(runId);
159
164
 
165
+ if (!path.isAbsolute(filePath)) {
166
+ filePath = path.join(process.cwd(), filePath);
167
+ }
168
+
160
169
  const data = { rid, file: filePath, uploaded };
161
170
  const jsonLine = `${JSON.stringify(data)}\n`;
162
171
 
@@ -170,6 +179,8 @@ class S3Uploader {
170
179
  async uploadFileByPath(filePath, pathInS3) {
171
180
  const [runId, rid] = pathInS3;
172
181
 
182
+ if (!filePath) return;
183
+
173
184
  if (!this.isEnabled) {
174
185
  this.storeUploadedFile(filePath, runId, rid, false);
175
186
  this.skippedUploadsCount++;
@@ -183,7 +194,6 @@ class S3Uploader {
183
194
  const isFileExist = await this.checkFileExists(filePath, 20, 500);
184
195
 
185
196
  if (!isFileExist) {
186
- this.failedUploadsCount++;
187
197
  console.error(chalk.yellow(`Artifacts file ${filePath} does not exist. Skipping...`));
188
198
  return;
189
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.6.0-beta-3-artifacts",
3
+ "version": "1.6.0-beta-5-artifacts",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",