ortoni-report 1.0.1 → 1.0.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.
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // ortoni-report.ts
30
+ // src/ortoni-report.ts
31
31
  var ortoni_report_exports = {};
32
32
  __export(ortoni_report_exports, {
33
33
  default: () => OrtoniReport
@@ -1,4 +1,4 @@
1
- // ortoni-report.ts
1
+ // src/ortoni-report.ts
2
2
  import fs from "fs";
3
3
  import path from "path";
4
4
  import Handlebars from "handlebars";
@@ -162,7 +162,7 @@
162
162
  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
163
163
  <script>
164
164
  document.addEventListener('DOMContentLoaded', () => {
165
- const testData = {{{ json results }}};
165
+ const testData = {{{ json results }}};
166
166
  const testDetails = document.getElementById('testDetails');
167
167
  const summary = document.getElementById('summary');
168
168
  const backButton = document.querySelector('.back-button');
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "ortoni-report",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Playwright Report By LetCode Koushik",
5
5
  "scripts": {
6
- "build": "tsup ortoni-report.ts --format cjs,esm --dts",
6
+ "build": "tsup",
7
7
  "release": "npm publish",
8
8
  "lint": "tsc"
9
9
  },
@@ -12,15 +12,11 @@
12
12
  "url": "git+https://github.com/ortoniKC/letcode-pw-report.git"
13
13
  },
14
14
  "keywords": [
15
- "playwright",
16
- "playwright",
17
- "report",
18
- "letcode",
19
- "koushik",
20
- "report",
21
- "ortoni",
22
- "ortoni",
23
- "report"
15
+ "playwright report",
16
+ "playwright letcode",
17
+ "letcode koushik",
18
+ "ortoni report",
19
+ "ortoni"
24
20
  ],
25
21
  "author": "Koushik Chatterjee (LetCode with Koushik)",
26
22
  "license": "ISC",
@@ -40,7 +36,7 @@
40
36
  "tsup": "^6.5.0",
41
37
  "typescript": "^4.9.4"
42
38
  },
43
- "main": "dist/index.js",
44
- "module": "dist/index.mjs",
45
- "types": "dist/index.d.ts"
39
+ "main": "dist/ortoni-report.js",
40
+ "module": "dist/ortoni-report.mjs",
41
+ "types": "dist/ortoni-report.d.ts"
46
42
  }
package/ortoni-report.ts DELETED
@@ -1,140 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import Handlebars from "handlebars";
4
- import colors from 'colors/safe';
5
-
6
- import type {
7
- FullConfig, FullResult, Reporter, Suite, TestCase, TestResult
8
- } from '@playwright/test/reporter';
9
-
10
- interface TestResultData {
11
- projectName: any;
12
- suite: any;
13
- title: string;
14
- status: string;
15
- duration: number;
16
- errors: any[];
17
- steps: any[];
18
- logs: string;
19
- screenshotPath: string | null;
20
- filePath: any;
21
- }
22
- export default class OrtoniReport implements Reporter {
23
- private results: TestResultData[] = [];
24
- private groupedResults: any;
25
- private suiteName: string | undefined | TestCase[];
26
-
27
- onBegin(config: FullConfig, suite: Suite) {
28
-
29
- this.results = [];
30
- const screenshotsDir = path.join(__dirname, 'screenshots');
31
- if (!fs.existsSync(screenshotsDir)) {
32
- fs.mkdirSync(screenshotsDir);
33
- }
34
- }
35
-
36
- onTestBegin(test: TestCase, result: TestResult) {
37
- }
38
-
39
- onTestEnd(test: TestCase, result: TestResult) {
40
- console.log(test.titlePath());
41
-
42
- const testResult: TestResultData = {
43
- projectName: test.titlePath()[1], // Get the project name
44
- suite: test.titlePath()[3], // Adjust the index based on your suite hierarchy
45
- title: test.title,
46
- status: result.status,
47
- duration: result.duration,
48
- errors: result.errors.map(e => colors.strip(e.message || e.toString())),
49
- steps: result.steps.map(step => ({
50
- title: step.title,
51
- category: step.category,
52
- duration: step.duration,
53
- status: result.status
54
- })),
55
- logs: colors.strip(result.stdout.concat(result.stderr).map(log => log).join('\n')),
56
- screenshotPath: null,
57
- filePath: test.titlePath()[2]
58
- };
59
-
60
- if (result.attachments) {
61
- const screenshotsDir = path.join(__dirname, 'screenshots\\' + test.id);
62
- if (!fs.existsSync(screenshotsDir)) {
63
- fs.mkdirSync(screenshotsDir);
64
- }
65
- const screenshot = result.attachments.find(attachment => attachment.name === 'screenshot');
66
- if (screenshot && screenshot.path) {
67
- const screenshotContent = fs.readFileSync(screenshot.path, 'base64');
68
- const screenshotFileName = `screenshots/${test.id}/${path.basename(screenshot.path)}`;
69
- fs.writeFileSync(path.join(__dirname, screenshotFileName), screenshotContent, 'base64');
70
- testResult.screenshotPath = screenshotFileName;
71
- }
72
- }
73
-
74
- this.results.push(testResult);
75
- }
76
-
77
- onEnd(result: FullResult) {
78
- this.groupedResults = this.results.reduce((acc: any, result, index) => {
79
- const filePath = result.filePath;
80
- const suiteName = result.suite;
81
- const projectName = result.projectName;
82
- if (!acc[filePath]) {
83
- acc[filePath] = {};
84
- }
85
- if (!acc[filePath][suiteName]) {
86
- acc[filePath][suiteName] = {};
87
- }
88
- if (!acc[filePath][suiteName][projectName]) {
89
- acc[filePath][suiteName][projectName] = [];
90
- }
91
- acc[filePath][suiteName][projectName].push({ ...result, index });
92
- return acc;
93
- }, {});
94
-
95
-
96
- // Register the json helper
97
- Handlebars.registerHelper('json', function (context) {
98
- return safeStringify(context);
99
- });
100
- Handlebars.registerHelper('splitSuiteName', function (suiteName) {
101
- return suiteName.split(' - ');
102
- });
103
- const html = this.generateHTML();
104
- const outputPath = path.join(__dirname, 'ortoni-report.html');
105
- fs.writeFileSync(outputPath, html);
106
- console.log(`Ortoni HTML report generated at ${outputPath}`);
107
- }
108
- generateHTML() {
109
- const templateSource = fs.readFileSync(path.join(__dirname, 'report-template.hbs'), 'utf-8');
110
- const template = Handlebars.compile(templateSource);
111
- const data = {
112
- suiteName: this.suiteName,
113
- results: this.results,
114
- passCount: this.results.filter(r => r.status === 'passed').length,
115
- failCount: this.results.filter(r => r.status === 'failed').length,
116
- skipCount: this.results.filter(r => r.status === 'skipped').length,
117
- retryCount: this.results.filter(r => r.status === 'retry').length,
118
- totalCount: this.results.length,
119
- groupedResults: this.groupedResults
120
- };
121
- return template(data);
122
- }
123
- }
124
- // Utility function to remove circular references
125
- function safeStringify(obj: any, indent = 2) {
126
- const cache = new Set();
127
- const json = JSON.stringify(obj, (key, value) => {
128
- if (typeof value === 'object' && value !== null) {
129
- if (cache.has(value)) {
130
- // Circular reference found, discard key
131
- return;
132
- }
133
- // Store value in our set
134
- cache.add(value);
135
- }
136
- return value;
137
- }, indent);
138
- cache.clear();
139
- return json;
140
- }
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Base Options: */
4
- "moduleResolution":"Node",
5
- "esModuleInterop": true,
6
- "skipLibCheck": true,
7
- "target": "es2022",
8
- "allowJs": true,
9
- "moduleDetection": "force",
10
- /* Strictness */
11
- "strict": true,
12
- "noUncheckedIndexedAccess": true,
13
- /* If NOT transpiling with TypeScript: */
14
- "module": "ESNext",
15
- "noEmit": true,
16
- /* If your code runs in the DOM: */
17
- "lib": ["es2022", "dom", "dom.iterable"],
18
- }
19
- }