monocart-reporter 1.7.7 → 1.7.9

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/visitor.js CHANGED
@@ -1,7 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const EC = require('eight-colors');
4
- const { StackUtils, codeFrameColumns } = require('./runtime/monocart-vendor.js');
4
+ const {
5
+ StackUtils, codeFrameColumns, sanitize
6
+ } = require('./runtime/monocart-vendor.js');
5
7
  const Util = require('./utils/util.js');
6
8
  const commentsPlugin = require('./plugins/comments.js');
7
9
  const defaultColumns = require('./default/columns.js');
@@ -523,6 +525,9 @@ class Visitor {
523
525
  this.reportHandler(item, 'coverage', title);
524
526
  this.reportHandler(item, 'network', title);
525
527
 
528
+ // content: text
529
+ this.contentHandler(item);
530
+
526
531
  const o = this.options;
527
532
  // store relative path first
528
533
  item.path = Util.relativePath(item.path, o.outputDir);
@@ -578,6 +583,12 @@ class Visitor {
578
583
 
579
584
  }
580
585
 
586
+ contentHandler(item) {
587
+ if (item.contentType && item.contentType.startsWith('text')) {
588
+ item.content = Util.readFileSync(item.path);
589
+ }
590
+ }
591
+
581
592
  saveAttachmentHandler(item, i, caseId) {
582
593
 
583
594
  const attachmentsPath = path.resolve(this.options.outputDir, caseId);
@@ -592,12 +603,14 @@ class Visitor {
592
603
  'application/octet-stream': 'data'
593
604
  };
594
605
 
606
+ const filename = sanitize(`${item.name}-${i + 1}`);
607
+
595
608
  let ext = 'data';
596
609
  const contentType = item.contentType;
597
610
  if (contentType) {
598
611
  ext = types[contentType] || contentType.split('/').pop().slice(0, 4);
599
612
  }
600
- const filePath = path.resolve(attachmentsPath, `${item.name}-${i + 1}.${ext}`);
613
+ const filePath = path.resolve(attachmentsPath, `${filename}.${ext}`);
601
614
  fs.writeFileSync(filePath, item.body);
602
615
  item.path = filePath;
603
616
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-reporter",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
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": {
@@ -52,10 +52,10 @@
52
52
  "open": "^9.1.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@playwright/test": "^1.37.1",
55
+ "@playwright/test": "^1.38.0",
56
56
  "axios": "^1.5.0",
57
57
  "dotenv": "^16.3.1",
58
- "eslint": "^8.48.0",
58
+ "eslint": "^8.49.0",
59
59
  "eslint-config-plus": "^1.0.6",
60
60
  "eslint-plugin-html": "^7.1.0",
61
61
  "eslint-plugin-vue": "^9.17.0",