@testomatio/reporter 1.0.12-beta.1 → 1.0.12-beta.3
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 +14 -6
- 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
|
@@ -39,8 +39,8 @@ class XmlReader {
|
|
|
39
39
|
if (!this.adapter) throw new Error('XML adapter for this format not found');
|
|
40
40
|
|
|
41
41
|
this.opts = opts || {};
|
|
42
|
-
|
|
43
|
-
this.pipes = pipesFactory(opts, store);
|
|
42
|
+
this.store = {}
|
|
43
|
+
this.pipes = pipesFactory(opts, this.store);
|
|
44
44
|
|
|
45
45
|
this.parser = new XMLParser(options);
|
|
46
46
|
this.tests = []
|
|
@@ -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,8 +353,12 @@ 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
|
-
|
|
353
|
-
|
|
356
|
+
|
|
357
|
+
if (!files.length) continue;
|
|
358
|
+
|
|
359
|
+
const runId = this.runId || this.store.runId || Date.now().toString();
|
|
360
|
+
test.artifacts = await Promise.all(files.map(f => upload.uploadFileByPath(f, runId)));
|
|
361
|
+
console.log(APP_PREFIX, `🗄️ Uploaded ${chalk.bold(`${files.length} artifacts`)} for test ${test.title}`);
|
|
354
362
|
}
|
|
355
363
|
}
|
|
356
364
|
|
|
@@ -360,8 +368,8 @@ class XmlReader {
|
|
|
360
368
|
title: this.requestParams.title,
|
|
361
369
|
env: this.requestParams.env,
|
|
362
370
|
group_title: this.requestParams.group_title,
|
|
363
|
-
};
|
|
364
|
-
|
|
371
|
+
};
|
|
372
|
+
|
|
365
373
|
debug("Run", runParams);
|
|
366
374
|
|
|
367
375
|
return Promise.all(this.pipes.map(p => p.createRun(runParams)));
|