monocart-reporter 1.7.9 → 1.7.10
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/README.md +3 -0
- package/lib/default/options.js +3 -0
- package/lib/generate-data.js +7 -1
- package/lib/platform/share.js +33 -0
- package/lib/runtime/monocart-common.js +1 -1
- package/lib/runtime/monocart-reporter.js +1 -1
- package/lib/runtime/monocart-vendor.js +8 -8
- package/lib/visitor.js +36 -8
- package/package.json +1 -1
package/lib/visitor.js
CHANGED
|
@@ -506,12 +506,13 @@ class Visitor {
|
|
|
506
506
|
|
|
507
507
|
if (item.body) {
|
|
508
508
|
if (!item.path) {
|
|
509
|
-
this.
|
|
509
|
+
this.saveAttachmentBodyHandler(item, i, caseId);
|
|
510
510
|
}
|
|
511
|
-
delete item.body;
|
|
512
511
|
}
|
|
513
512
|
|
|
513
|
+
// text attachment may no path
|
|
514
514
|
if (!item.path) {
|
|
515
|
+
list.push(item);
|
|
515
516
|
return;
|
|
516
517
|
}
|
|
517
518
|
|
|
@@ -584,12 +585,38 @@ class Visitor {
|
|
|
584
585
|
}
|
|
585
586
|
|
|
586
587
|
contentHandler(item) {
|
|
587
|
-
if (item.
|
|
588
|
+
if (item.content) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (Util.isTextType(item.contentType)) {
|
|
588
592
|
item.content = Util.readFileSync(item.path);
|
|
589
593
|
}
|
|
590
594
|
}
|
|
591
595
|
|
|
592
|
-
|
|
596
|
+
contentToString(content) {
|
|
597
|
+
if (typeof content === 'string') {
|
|
598
|
+
return content;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (Buffer.isBuffer(content)) {
|
|
602
|
+
return content.toString('utf8');
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return content.toString();
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
saveAttachmentBodyHandler(item, i, caseId) {
|
|
609
|
+
|
|
610
|
+
const content = item.body;
|
|
611
|
+
delete item.body;
|
|
612
|
+
|
|
613
|
+
// if text content no need save file, just show the content
|
|
614
|
+
const contentType = item.contentType;
|
|
615
|
+
if (Util.isTextType(contentType)) {
|
|
616
|
+
// body is buffer
|
|
617
|
+
item.content = this.contentToString(content);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
593
620
|
|
|
594
621
|
const attachmentsPath = path.resolve(this.options.outputDir, caseId);
|
|
595
622
|
if (!fs.existsSync(attachmentsPath)) {
|
|
@@ -598,21 +625,22 @@ class Visitor {
|
|
|
598
625
|
});
|
|
599
626
|
}
|
|
600
627
|
|
|
628
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
601
629
|
const types = {
|
|
602
630
|
'text/plain': 'txt',
|
|
603
|
-
'application/octet-stream': '
|
|
631
|
+
'application/octet-stream': 'bin'
|
|
604
632
|
};
|
|
605
633
|
|
|
606
634
|
const filename = sanitize(`${item.name}-${i + 1}`);
|
|
607
635
|
|
|
608
|
-
let ext = '
|
|
609
|
-
const contentType = item.contentType;
|
|
636
|
+
let ext = 'bin';
|
|
610
637
|
if (contentType) {
|
|
611
638
|
ext = types[contentType] || contentType.split('/').pop().slice(0, 4);
|
|
612
639
|
}
|
|
613
640
|
const filePath = path.resolve(attachmentsPath, `${filename}.${ext}`);
|
|
614
|
-
fs.writeFileSync(filePath,
|
|
641
|
+
fs.writeFileSync(filePath, content);
|
|
615
642
|
item.path = filePath;
|
|
643
|
+
|
|
616
644
|
}
|
|
617
645
|
|
|
618
646
|
locationHandler(location) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.10",
|
|
4
4
|
"description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|