@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.
- package/lib/bin/reportXml.js +1 -0
- package/lib/util.js +14 -4
- package/lib/xmlReader.js +7 -3
- package/package.json +1 -1
package/lib/bin/reportXml.js
CHANGED
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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)));
|