@testomatio/reporter 1.0.12-beta.1 → 1.0.12-beta.2

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.
@@ -23,6 +23,7 @@ program
23
23
  }
24
24
  let { javaTests, lang } = opts;
25
25
  if (opts.envFile) {
26
+ console.log(APP_PREFIX, 'Loading env file:', opts.envFile);
26
27
  debug('Loading env file: %s', opts.envFile)
27
28
  require('dotenv').config({ path: opts.envFile }); // eslint-disable-line
28
29
  }
package/lib/util.js CHANGED
@@ -55,11 +55,21 @@ const isValidUrl = s => {
55
55
  }
56
56
  };
57
57
 
58
+ const fileMatchRegex = /file:(\/\/?[^:\s]+?\.(png|avi|webm|jpg|html|txt))/ig;
59
+
58
60
  const fetchFilesFromStackTrace = (stack = '') => {
59
- const files = stack.matchAll(/file:?\/(\/?[^:\s]+?\.(png|avi|webm|jpg|html|txt))/ig);
60
- return Array.from(files)
61
- .map(f => f[1])
62
- .filter(f => fs.existsSync(f));
61
+
62
+ const files = Array.from(stack.matchAll(fileMatchRegex))
63
+ .map(f => f[1].trim())
64
+ .map(f => f.startsWith('//') ? f.substring(1) : f )
65
+
66
+ debug('Found files in stack trace: ', files);
67
+
68
+ return files.filter(f => {
69
+ const isFile = fs.existsSync(f);
70
+ if (!isFile) debug('File %s could not be found and uploaded as artifact', f);
71
+ return isFile;
72
+ });
63
73
  };
64
74
 
65
75
  const fetchSourceCodeFromStackTrace = (stack = '') => {
package/lib/xmlReader.js CHANGED
@@ -304,6 +304,10 @@ class XmlReader {
304
304
  if (file.endsWith('.ts')) this.stats.language = 'ts';
305
305
  }
306
306
 
307
+ if (!fs.existsSync(file)) {
308
+ debug('Failed to open file with the source code', file)
309
+ return;
310
+ }
307
311
  const contents = fs.readFileSync(file).toString();
308
312
  t.code = fetchSourceCode(contents, { ...t, lang: this.stats.language })
309
313
  } catch (err) {
@@ -349,7 +353,7 @@ class XmlReader {
349
353
  let files = [];
350
354
  if (test.files?.length) files = test.files.map(f => path.join(process.cwd(), f))
351
355
  files = [...files, ...fetchFilesFromStackTrace(test.stack)];
352
- debug('Uploading files', files)
356
+ console.log(APP_PREFIX, 'Uploading files', files)
353
357
  test.artifacts = await Promise.all(files.map(f => upload.uploadFileByPath(f, this.runId)));
354
358
  }
355
359
  }
@@ -360,8 +364,8 @@ class XmlReader {
360
364
  title: this.requestParams.title,
361
365
  env: this.requestParams.env,
362
366
  group_title: this.requestParams.group_title,
363
- };
364
-
367
+ };
368
+
365
369
  debug("Run", runParams);
366
370
 
367
371
  return Promise.all(this.pipes.map(p => p.createRun(runParams)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.0.12-beta.1",
3
+ "version": "1.0.12-beta.2",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",