ortoni-report 1.1.3 → 1.1.5

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.
@@ -1,9 +1,10 @@
1
1
  import { TestStep, Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
2
2
 
3
- interface ReporterConfig {
3
+ interface OrtoniReportConfig {
4
4
  projectName?: string;
5
5
  authorName?: string;
6
6
  testType?: string;
7
+ preferredTheme?: 'light' | 'dark';
7
8
  }
8
9
 
9
10
  interface TestResultData {
@@ -20,6 +21,7 @@ interface TestResultData {
20
21
  logs: string;
21
22
  screenshotPath: string | null;
22
23
  filePath: any;
24
+ projects: Set<string>;
23
25
  }
24
26
 
25
27
  declare class OrtoniReport implements Reporter {
@@ -27,12 +29,13 @@ declare class OrtoniReport implements Reporter {
27
29
  private groupedResults;
28
30
  private suiteName;
29
31
  private config;
30
- constructor(config?: ReporterConfig);
32
+ constructor(config?: OrtoniReportConfig);
31
33
  onBegin(config: FullConfig, suite: Suite): void;
32
34
  onTestBegin(test: TestCase, result: TestResult): void;
35
+ private projectSet;
33
36
  onTestEnd(test: TestCase, result: TestResult): void;
34
37
  onEnd(result: FullResult): void;
35
38
  generateHTML(filteredResults: TestResultData[], totalDuration: string): string;
36
39
  }
37
40
 
38
- export { OrtoniReport as default };
41
+ export { OrtoniReportConfig, OrtoniReport as default };
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/ortoni-report.ts
31
31
  var ortoni_report_exports = {};
32
32
  __export(ortoni_report_exports, {
33
- default: () => ortoni_report_default
33
+ default: () => OrtoniReport
34
34
  });
35
35
  module.exports = __toCommonJS(ortoni_report_exports);
36
36
  var import_fs = __toESM(require("fs"));
@@ -47,16 +47,18 @@ function msToTime(duration) {
47
47
  const hours = Math.floor(duration / (1e3 * 60 * 60) % 24);
48
48
  let result = "";
49
49
  if (hours > 0) {
50
- result += (hours < 10 ? "0" + hours : hours) + "h:";
50
+ result += `${hours}h:`;
51
51
  }
52
52
  if (minutes > 0 || hours > 0) {
53
- result += (minutes < 10 ? "0" + minutes : minutes) + "m:";
53
+ result += `${minutes < 10 ? "0" + minutes : minutes}m:`;
54
54
  }
55
55
  if (seconds > 0 || minutes > 0 || hours > 0) {
56
- result += (seconds < 10 ? "0" + seconds : seconds) + "s";
56
+ result += `${seconds < 10 ? "0" + seconds : seconds}s`;
57
57
  }
58
- if (milliseconds > 0) {
59
- result += ":" + (milliseconds < 100 ? "0" + milliseconds : milliseconds) + "ms";
58
+ if (milliseconds > 0 && !(seconds > 0 || minutes > 0 || hours > 0)) {
59
+ result += `${milliseconds}ms`;
60
+ } else if (milliseconds > 0) {
61
+ result += `:${milliseconds < 100 ? "0" + milliseconds : milliseconds}ms`;
60
62
  }
61
63
  return result;
62
64
  }
@@ -76,15 +78,11 @@ function formatDate(date) {
76
78
  var OrtoniReport = class {
77
79
  constructor(config = {}) {
78
80
  this.results = [];
81
+ this.projectSet = /* @__PURE__ */ new Set();
79
82
  this.config = config;
80
83
  }
81
84
  onBegin(config, suite) {
82
85
  this.results = [];
83
- const screenshotsDir = import_path2.default.resolve(process.cwd(), "screenshots");
84
- if (import_fs.default.existsSync(screenshotsDir)) {
85
- import_fs.default.rmSync(screenshotsDir, { recursive: true, force: true });
86
- }
87
- import_fs.default.mkdirSync(screenshotsDir, { recursive: true });
88
86
  }
89
87
  onTestBegin(test, result) {
90
88
  }
@@ -93,6 +91,7 @@ var OrtoniReport = class {
93
91
  if (test.outcome() === "flaky") {
94
92
  status = "flaky";
95
93
  }
94
+ this.projectSet.add(test.titlePath()[1]);
96
95
  const testResult = {
97
96
  retry: result.retry > 0 ? "retry" : "",
98
97
  isRetry: result.retry,
@@ -116,19 +115,14 @@ var OrtoniReport = class {
116
115
  })),
117
116
  logs: import_safe.default.strip(result.stdout.concat(result.stderr).map((log) => log).join("\n")),
118
117
  screenshotPath: null,
119
- filePath: normalizeFilePath(test.titlePath()[2])
118
+ filePath: normalizeFilePath(test.titlePath()[2]),
119
+ projects: this.projectSet
120
120
  };
121
121
  if (result.attachments) {
122
- const screenshotsDir = import_path2.default.resolve(process.cwd(), "screenshots", test.id);
123
- if (!import_fs.default.existsSync(screenshotsDir)) {
124
- import_fs.default.mkdirSync(screenshotsDir, { recursive: true });
125
- }
126
122
  const screenshot = result.attachments.find((attachment) => attachment.name === "screenshot");
127
123
  if (screenshot && screenshot.path) {
128
124
  const screenshotContent = import_fs.default.readFileSync(screenshot.path, "base64");
129
- const screenshotFileName = import_path2.default.join("screenshots", test.id, import_path2.default.basename(screenshot.path));
130
- import_fs.default.writeFileSync(import_path2.default.resolve(process.cwd(), screenshotFileName), screenshotContent, "base64");
131
- testResult.screenshotPath = screenshotFileName;
125
+ testResult.screenshotPath = screenshotContent;
132
126
  }
133
127
  }
134
128
  this.results.push(testResult);
@@ -198,8 +192,10 @@ var OrtoniReport = class {
198
192
  projectName: this.config.projectName,
199
193
  authorName: this.config.authorName,
200
194
  testType: this.config.testType,
195
+ preferredTheme: this.config.preferredTheme,
201
196
  successRate,
202
- lastRunDate: formatDate(/* @__PURE__ */ new Date())
197
+ lastRunDate: formatDate(/* @__PURE__ */ new Date()),
198
+ projects: this.projectSet
203
199
  };
204
200
  return template(data);
205
201
  }
@@ -218,4 +214,3 @@ function safeStringify(obj, indent = 2) {
218
214
  cache.clear();
219
215
  return json;
220
216
  }
221
- var ortoni_report_default = OrtoniReport;
@@ -13,16 +13,18 @@ function msToTime(duration) {
13
13
  const hours = Math.floor(duration / (1e3 * 60 * 60) % 24);
14
14
  let result = "";
15
15
  if (hours > 0) {
16
- result += (hours < 10 ? "0" + hours : hours) + "h:";
16
+ result += `${hours}h:`;
17
17
  }
18
18
  if (minutes > 0 || hours > 0) {
19
- result += (minutes < 10 ? "0" + minutes : minutes) + "m:";
19
+ result += `${minutes < 10 ? "0" + minutes : minutes}m:`;
20
20
  }
21
21
  if (seconds > 0 || minutes > 0 || hours > 0) {
22
- result += (seconds < 10 ? "0" + seconds : seconds) + "s";
22
+ result += `${seconds < 10 ? "0" + seconds : seconds}s`;
23
23
  }
24
- if (milliseconds > 0) {
25
- result += ":" + (milliseconds < 100 ? "0" + milliseconds : milliseconds) + "ms";
24
+ if (milliseconds > 0 && !(seconds > 0 || minutes > 0 || hours > 0)) {
25
+ result += `${milliseconds}ms`;
26
+ } else if (milliseconds > 0) {
27
+ result += `:${milliseconds < 100 ? "0" + milliseconds : milliseconds}ms`;
26
28
  }
27
29
  return result;
28
30
  }
@@ -42,15 +44,11 @@ function formatDate(date) {
42
44
  var OrtoniReport = class {
43
45
  constructor(config = {}) {
44
46
  this.results = [];
47
+ this.projectSet = /* @__PURE__ */ new Set();
45
48
  this.config = config;
46
49
  }
47
50
  onBegin(config, suite) {
48
51
  this.results = [];
49
- const screenshotsDir = path2.resolve(process.cwd(), "screenshots");
50
- if (fs.existsSync(screenshotsDir)) {
51
- fs.rmSync(screenshotsDir, { recursive: true, force: true });
52
- }
53
- fs.mkdirSync(screenshotsDir, { recursive: true });
54
52
  }
55
53
  onTestBegin(test, result) {
56
54
  }
@@ -59,6 +57,7 @@ var OrtoniReport = class {
59
57
  if (test.outcome() === "flaky") {
60
58
  status = "flaky";
61
59
  }
60
+ this.projectSet.add(test.titlePath()[1]);
62
61
  const testResult = {
63
62
  retry: result.retry > 0 ? "retry" : "",
64
63
  isRetry: result.retry,
@@ -82,19 +81,14 @@ var OrtoniReport = class {
82
81
  })),
83
82
  logs: colors.strip(result.stdout.concat(result.stderr).map((log) => log).join("\n")),
84
83
  screenshotPath: null,
85
- filePath: normalizeFilePath(test.titlePath()[2])
84
+ filePath: normalizeFilePath(test.titlePath()[2]),
85
+ projects: this.projectSet
86
86
  };
87
87
  if (result.attachments) {
88
- const screenshotsDir = path2.resolve(process.cwd(), "screenshots", test.id);
89
- if (!fs.existsSync(screenshotsDir)) {
90
- fs.mkdirSync(screenshotsDir, { recursive: true });
91
- }
92
88
  const screenshot = result.attachments.find((attachment) => attachment.name === "screenshot");
93
89
  if (screenshot && screenshot.path) {
94
90
  const screenshotContent = fs.readFileSync(screenshot.path, "base64");
95
- const screenshotFileName = path2.join("screenshots", test.id, path2.basename(screenshot.path));
96
- fs.writeFileSync(path2.resolve(process.cwd(), screenshotFileName), screenshotContent, "base64");
97
- testResult.screenshotPath = screenshotFileName;
91
+ testResult.screenshotPath = screenshotContent;
98
92
  }
99
93
  }
100
94
  this.results.push(testResult);
@@ -164,8 +158,10 @@ var OrtoniReport = class {
164
158
  projectName: this.config.projectName,
165
159
  authorName: this.config.authorName,
166
160
  testType: this.config.testType,
161
+ preferredTheme: this.config.preferredTheme,
167
162
  successRate,
168
- lastRunDate: formatDate(/* @__PURE__ */ new Date())
163
+ lastRunDate: formatDate(/* @__PURE__ */ new Date()),
164
+ projects: this.projectSet
169
165
  };
170
166
  return template(data);
171
167
  }
@@ -184,7 +180,6 @@ function safeStringify(obj, indent = 2) {
184
180
  cache.clear();
185
181
  return json;
186
182
  }
187
- var ortoni_report_default = OrtoniReport;
188
183
  export {
189
- ortoni_report_default as default
184
+ OrtoniReport as default
190
185
  };