playwright-fire-reports 1.0.0

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.
@@ -0,0 +1,83 @@
1
+ export function calculateStatistics(data) {
2
+ const durationByStatus = {
3
+ passed: 0,
4
+ failed: 0,
5
+ skipped: 0
6
+ };
7
+ const retriesMap = {};
8
+ let maxDuration = 0;
9
+ let minDuration = Infinity;
10
+ // Calculate durations and retries
11
+ for (const test of data.tests) {
12
+ if (test.status === 'passed')
13
+ durationByStatus.passed += test.duration;
14
+ if (test.status === 'failed')
15
+ durationByStatus.failed += test.duration;
16
+ if (test.status === 'skipped')
17
+ durationByStatus.skipped += test.duration;
18
+ maxDuration = Math.max(maxDuration, test.duration);
19
+ minDuration = Math.min(minDuration, test.duration);
20
+ retriesMap[test.retries] = (retriesMap[test.retries] || 0) + 1;
21
+ }
22
+ minDuration = minDuration === Infinity ? 0 : minDuration;
23
+ // Duration ranges
24
+ const durationRanges = {
25
+ fast: 0,
26
+ medium: 0,
27
+ slow: 0,
28
+ verySlow: 0
29
+ };
30
+ for (const test of data.tests) {
31
+ if (test.duration < 1000)
32
+ durationRanges.fast++;
33
+ else if (test.duration < 5000)
34
+ durationRanges.medium++;
35
+ else if (test.duration < 15000)
36
+ durationRanges.slow++;
37
+ else
38
+ durationRanges.verySlow++;
39
+ }
40
+ // Get failed, flaky, and slowest tests
41
+ const failedTests = data.tests.filter(t => t.status === 'failed');
42
+ const flakyTests = data.tests.filter(t => t.retries > 0 && t.status === 'passed');
43
+ const slowestTests = [...data.tests].sort((a, b) => b.duration - a.duration).slice(0, 10);
44
+ return {
45
+ passRate: data.totalTests > 0 ? Math.round((data.passed / data.totalTests) * 100) : 0,
46
+ failRate: data.totalTests > 0 ? Math.round((data.failed / data.totalTests) * 100) : 0,
47
+ skipRate: data.totalTests > 0 ? Math.round((data.skipped / data.totalTests) * 100) : 0,
48
+ averageDuration: data.totalTests > 0 ? Math.round(data.totalDuration / data.totalTests) : 0,
49
+ maxDuration,
50
+ minDuration,
51
+ durationByStatus,
52
+ retriesDistribution: retriesMap,
53
+ durationRanges,
54
+ failedTests,
55
+ flakyTests,
56
+ slowestTests
57
+ };
58
+ }
59
+ export function formatDuration(ms) {
60
+ if (ms < 1000)
61
+ return `${Math.round(ms)}ms`;
62
+ if (ms < 60000)
63
+ return `${(ms / 1000).toFixed(2)}s`;
64
+ return `${Math.floor(ms / 60000)}m ${Math.round((ms % 60000) / 1000)}s`;
65
+ }
66
+ export function getStatusColor(status) {
67
+ switch (status) {
68
+ case 'passed': return '#10b981';
69
+ case 'failed': return '#ef4444';
70
+ case 'skipped': return '#f59e0b';
71
+ case 'timedOut': return '#8b5cf6';
72
+ default: return '#6b7280';
73
+ }
74
+ }
75
+ export function getStatusIcon(status) {
76
+ switch (status) {
77
+ case 'passed': return '✓';
78
+ case 'failed': return '✕';
79
+ case 'skipped': return '⊘';
80
+ case 'timedOut': return '⏱';
81
+ default: return '?';
82
+ }
83
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "playwright-fire-reports",
3
+ "version": "1.0.0",
4
+ "description": "Playwright Fire Reports - Stunning HTML report generator for Playwright test results with beautiful charts, multiple themes, and advanced analytics",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "start": "node dist/cli.js",
11
+ "generate-report": "node dist/cli.js",
12
+ "dev": "tsc --watch",
13
+ "example": "node dist/cli.js --input ./sample-report.json --output ./reports/report.html --theme dark",
14
+ "quickstart": "node quickstart.js"
15
+ },
16
+ "keywords": [
17
+ "playwright",
18
+ "test-report",
19
+ "html-report",
20
+ "charts",
21
+ "visualization",
22
+ "automation",
23
+ "testing",
24
+ "fire-reports",
25
+ "beautiful-reports",
26
+ "test-analytics"
27
+ ],
28
+ "author": "Your Name",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/yourusername/playwright-fire-reports.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/yourusername/playwright-fire-reports/issues"
36
+ },
37
+ "homepage": "https://github.com/yourusername/playwright-fire-reports#readme",
38
+ "files": [
39
+ "dist",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "bin": {
44
+ "fire-report": "dist/cli.js"
45
+ },
46
+ "dependencies": {
47
+ "chalk": "^4.1.2",
48
+ "fs-extra": "^11.2.0",
49
+ "handlebars": "^4.7.7",
50
+ "yargs": "^17.7.2"
51
+ },
52
+ "devDependencies": {
53
+ "@types/fs-extra": "^11.0.4",
54
+ "@types/node": "^20.10.6",
55
+ "@types/yargs": "^17.0.35",
56
+ "typescript": "^5.3.3"
57
+ },
58
+ "engines": {
59
+ "node": ">=14.0.0"
60
+ }
61
+ }