ortoni-report 4.0.2 → 4.0.4

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.
Files changed (37) hide show
  1. package/changelog.md +10 -0
  2. package/dist/chunk-L6VOLEP2.mjs +752 -0
  3. package/dist/cli.js +27 -21
  4. package/dist/cli.mjs +1 -1
  5. package/dist/helpers/HTMLGenerator.d.ts +89 -0
  6. package/dist/helpers/HTMLGenerator.js +164 -0
  7. package/dist/helpers/databaseManager.d.ts +35 -0
  8. package/dist/helpers/databaseManager.js +267 -0
  9. package/dist/helpers/fileManager.d.ts +8 -0
  10. package/dist/helpers/fileManager.js +60 -0
  11. package/dist/helpers/markdownConverter.d.ts +1 -0
  12. package/dist/helpers/markdownConverter.js +14 -0
  13. package/dist/helpers/resultProcessor.d.ts +10 -0
  14. package/dist/helpers/resultProcessor.js +60 -0
  15. package/dist/helpers/serverManager.d.ts +6 -0
  16. package/dist/helpers/serverManager.js +15 -0
  17. package/dist/helpers/templateLoader.d.ts +15 -0
  18. package/dist/helpers/templateLoader.js +88 -0
  19. package/dist/index.html +2 -2
  20. package/dist/mergeData.d.ts +13 -0
  21. package/dist/mergeData.js +182 -0
  22. package/dist/ortoni-report.js +72 -64
  23. package/dist/ortoni-report.mjs +2 -2
  24. package/dist/types/reporterConfig.d.ts +86 -0
  25. package/dist/types/reporterConfig.js +1 -0
  26. package/dist/types/testResults.d.ts +31 -0
  27. package/dist/types/testResults.js +1 -0
  28. package/dist/utils/attachFiles.d.ts +4 -0
  29. package/dist/utils/attachFiles.js +87 -0
  30. package/dist/utils/expressServer.d.ts +1 -0
  31. package/dist/utils/expressServer.js +61 -0
  32. package/dist/utils/groupProjects.d.ts +3 -0
  33. package/dist/utils/groupProjects.js +30 -0
  34. package/dist/utils/utils.d.ts +15 -0
  35. package/dist/utils/utils.js +93 -0
  36. package/package.json +1 -1
  37. package/readme.md +1 -1
@@ -0,0 +1,61 @@
1
+ import express from "express";
2
+ import path from "path";
3
+ import { spawn } from "child_process";
4
+ export function startReportServer(reportFolder, reportFilename, port = 2004, open) {
5
+ const app = express();
6
+ app.use(express.static(reportFolder, { index: false }));
7
+ app.get("/", (_req, res) => {
8
+ try {
9
+ res.sendFile(path.resolve(reportFolder, reportFilename));
10
+ }
11
+ catch (error) {
12
+ console.error("Ortoni Report: Error sending report file:", error);
13
+ res.status(500).send("Error loading report");
14
+ }
15
+ });
16
+ try {
17
+ const server = app.listen(port, () => {
18
+ console.log(`Server is running at http://localhost:${port} \nPress Ctrl+C to stop.`);
19
+ if (open === "always" || open === "on-failure") {
20
+ try {
21
+ openBrowser(`http://localhost:${port}`);
22
+ }
23
+ catch (error) {
24
+ console.error("Ortoni Report: Error opening browser:", error);
25
+ }
26
+ }
27
+ });
28
+ server.on("error", (error) => {
29
+ if (error.code === "EADDRINUSE") {
30
+ console.error(`Ortoni Report: Port ${port} is already in use. Trying a different port...`);
31
+ }
32
+ else {
33
+ console.error("Ortoni Report: Server error:", error);
34
+ }
35
+ });
36
+ }
37
+ catch (error) {
38
+ console.error("Ortoni Report: Error starting the server:", error);
39
+ }
40
+ }
41
+ function openBrowser(url) {
42
+ const platform = process.platform;
43
+ let command;
44
+ try {
45
+ if (platform === "win32") {
46
+ command = "cmd";
47
+ spawn(command, ["/c", "start", url]);
48
+ }
49
+ else if (platform === "darwin") {
50
+ command = "open";
51
+ spawn(command, [url]);
52
+ }
53
+ else {
54
+ command = "xdg-open";
55
+ spawn(command, [url]);
56
+ }
57
+ }
58
+ catch (error) {
59
+ console.error("Ortoni Report: Error opening the browser:", error);
60
+ }
61
+ }
@@ -0,0 +1,3 @@
1
+ import { OrtoniReportConfig } from "../types/reporterConfig";
2
+ import { TestResultData } from "../types/testResults";
3
+ export declare function groupResults(config: OrtoniReportConfig, results: TestResultData[]): any;
@@ -0,0 +1,30 @@
1
+ export function groupResults(config, results) {
2
+ if (config.showProject) {
3
+ // Group by filePath, suite, and projectName
4
+ const groupedResults = results.reduce((acc, result, index) => {
5
+ const testId = `${result.filePath}:${result.projectName}:${result.title}`;
6
+ const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
7
+ const { filePath, suite, projectName } = result;
8
+ acc[filePath] = acc[filePath] || {};
9
+ acc[filePath][suite] = acc[filePath][suite] || {};
10
+ acc[filePath][suite][projectName] =
11
+ acc[filePath][suite][projectName] || [];
12
+ acc[filePath][suite][projectName].push({ ...result, index, testId, key });
13
+ return acc;
14
+ }, {});
15
+ return groupedResults;
16
+ }
17
+ else {
18
+ // Group by filePath and suite, ignoring projectName
19
+ const groupedResults = results.reduce((acc, result, index) => {
20
+ const testId = `${result.filePath}:${result.projectName}:${result.title}`;
21
+ const key = `${testId}-${result.key}-${result.retryAttemptCount}`;
22
+ const { filePath, suite } = result;
23
+ acc[filePath] = acc[filePath] || {};
24
+ acc[filePath][suite] = acc[filePath][suite] || [];
25
+ acc[filePath][suite].push({ ...result, index, testId, key });
26
+ return acc;
27
+ }, {});
28
+ return groupedResults;
29
+ }
30
+ }
@@ -0,0 +1,15 @@
1
+ export declare function normalizeFilePath(filePath: string): string;
2
+ export declare function formatDate(date: Date): string;
3
+ export declare function safeStringify(obj: any, indent?: number): string;
4
+ export declare function ensureHtmlExtension(filename: string): string;
5
+ export declare function escapeHtml(unsafe: string): string;
6
+ export declare function formatDateUTC(date: Date): string;
7
+ export declare function formatDateLocal(dateInput: Date | string | undefined | null): string;
8
+ export declare function formatDateNoTimezone(isoString: string): string;
9
+ type SuiteAndTitle = {
10
+ hierarchy: string;
11
+ topLevelSuite: string;
12
+ parentSuite: string;
13
+ };
14
+ export declare function extractSuites(titlePath: string[]): SuiteAndTitle;
15
+ export {};
@@ -0,0 +1,93 @@
1
+ import path from "path";
2
+ export function normalizeFilePath(filePath) {
3
+ // Normalize the path to handle different separators
4
+ const normalizedPath = path.normalize(filePath);
5
+ // Get the base name of the file (removes any leading directories)
6
+ return path.basename(normalizedPath);
7
+ }
8
+ export function formatDate(date) {
9
+ const day = String(date.getDate()).padStart(2, "0");
10
+ const month = date.toLocaleString("default", { month: "short" });
11
+ const year = date.getFullYear();
12
+ const time = date.toLocaleTimeString();
13
+ return `${day}-${month}-${year} ${time}`;
14
+ }
15
+ export function safeStringify(obj, indent = 2) {
16
+ const cache = new Set();
17
+ const json = JSON.stringify(obj, (key, value) => {
18
+ if (typeof value === "object" && value !== null) {
19
+ if (cache.has(value)) {
20
+ return;
21
+ }
22
+ cache.add(value);
23
+ }
24
+ return value;
25
+ }, indent);
26
+ cache.clear();
27
+ return json;
28
+ }
29
+ export function ensureHtmlExtension(filename) {
30
+ const ext = path.extname(filename);
31
+ if (ext && ext.toLowerCase() === ".html") {
32
+ return filename;
33
+ }
34
+ return `${filename}.html`;
35
+ }
36
+ export function escapeHtml(unsafe) {
37
+ if (typeof unsafe !== "string") {
38
+ return String(unsafe);
39
+ }
40
+ return unsafe.replace(/[&<"']/g, function (match) {
41
+ const escapeMap = {
42
+ "&": "&amp;",
43
+ "<": "&lt;",
44
+ ">": "&gt;",
45
+ '"': "&quot;",
46
+ "'": "&#039;",
47
+ };
48
+ return escapeMap[match] || match;
49
+ });
50
+ }
51
+ export function formatDateUTC(date) {
52
+ return date.toISOString();
53
+ }
54
+ export function formatDateLocal(dateInput) {
55
+ if (!dateInput)
56
+ return "N/A";
57
+ try {
58
+ const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
59
+ if (isNaN(date.getTime())) {
60
+ return "N/A";
61
+ }
62
+ const options = {
63
+ year: "numeric",
64
+ month: "short",
65
+ day: "2-digit",
66
+ hour: "2-digit",
67
+ minute: "2-digit",
68
+ hour12: true,
69
+ };
70
+ return new Intl.DateTimeFormat("en-US", options).format(date);
71
+ }
72
+ catch (e) {
73
+ return "N/A";
74
+ }
75
+ }
76
+ export function formatDateNoTimezone(isoString) {
77
+ const date = new Date(isoString);
78
+ return date.toLocaleString("en-US", {
79
+ dateStyle: "medium",
80
+ timeStyle: "short",
81
+ });
82
+ }
83
+ export function extractSuites(titlePath) {
84
+ const tagPattern = /@[\w]+/g;
85
+ const suiteParts = titlePath
86
+ .slice(3, titlePath.length - 1)
87
+ .map((p) => p.replace(tagPattern, "").trim());
88
+ return {
89
+ hierarchy: suiteParts.join(" > "),
90
+ topLevelSuite: suiteParts[0] ?? "",
91
+ parentSuite: suiteParts[suiteParts.length - 1] ?? "", // last suite
92
+ };
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ortoni-report",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "Playwright Report By LetCode with Koushik",
5
5
  "scripts": {
6
6
  "tsc": "tsc",
package/readme.md CHANGED
@@ -201,7 +201,7 @@ Developed and designed by [Koushik Chatterjee](https://letcode.in/contact)
201
201
  **Tech Stack**
202
202
 
203
203
  1. Report generated using Playwright custom report
204
- 2. UI - React and Shadcn UI
204
+ 2. [UI - React and Shadcn UI](https://github.com/ortoniKC/ortoni-report-react)
205
205
  3. DB - sqlite
206
206
  4. Local host - express
207
207