@arghajit/dummy 0.1.2-beta-11 → 0.1.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.
- package/README.md +1 -1
- package/dist/reporter/attachment-utils.d.ts +9 -27
- package/dist/reporter/attachment-utils.js +62 -34
- package/dist/reporter/index.d.ts +2 -0
- package/dist/reporter/index.js +3 -0
- package/dist/reporter/playwright-pulse-reporter.d.ts +17 -112
- package/dist/reporter/playwright-pulse-reporter.js +470 -389
- package/dist/types/index.d.ts +2 -4
- package/package.json +8 -5
- package/scripts/generate-static-report.mjs +33 -47
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ The project provides these utility commands:
|
|
|
16
16
|
| Command | Description |
|
|
17
17
|
|------------------------|-----------------------------------------------------------------------------|
|
|
18
18
|
| `generate-report` | Generates playwright-pulse-report.html, Loads screenshots and images dynamically from the attachments/ directory, Produces a lighter HTML file with faster initial load, Requires attachments/ directory to be present when viewing the report |
|
|
19
|
-
| `generate-pulse-report`| Generates `playwright-pulse-static-report.html`, Self-contained, no server required, Preserves all dashboard functionality, all the attachments are embadded in the report, no need to have attachments/ directory when viewing the report
|
|
19
|
+
| `generate-pulse-report`| Generates `playwright-pulse-static-report.html`, Self-contained, no server required, Preserves all dashboard functionality, all the attachments are embadded in the report, no need to have attachments/ directory when viewing the report, with a dark theme and better initial load handling |
|
|
20
20
|
| `merge-pulse-report` | Combines multiple parallel test json reports, basically used in sharding |
|
|
21
21
|
| `generate-trend` | Analyzes historical trends in test results |
|
|
22
22
|
| `generate-email-report`| Generates email-friendly report versions |
|
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
interface PlaywrightPulseReporterOptions {
|
|
11
|
-
outputDir?: string;
|
|
12
|
-
outputFile?: string;
|
|
13
|
-
base64Images?: boolean;
|
|
14
|
-
open?: boolean;
|
|
15
|
-
resetOnEachRun?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface TestResult {
|
|
18
|
-
screenshots?: string[];
|
|
19
|
-
videoPath?: string[];
|
|
20
|
-
tracePath?: string;
|
|
21
|
-
attachments?: Array<{
|
|
22
|
-
name: string;
|
|
23
|
-
path: string;
|
|
24
|
-
contentType?: string;
|
|
25
|
-
}>;
|
|
26
|
-
}
|
|
1
|
+
import type { TestResult as PwTestResult } from "@playwright/test/reporter";
|
|
2
|
+
import type { TestResult, PlaywrightPulseReporterOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Processes attachments from a Playwright TestResult and updates the PulseTestResult.
|
|
5
|
+
* @param testId A unique identifier for the test, used for folder naming.
|
|
6
|
+
* @param pwResult The TestResult object from Playwright.
|
|
7
|
+
* @param pulseResult The internal test result structure to update.
|
|
8
|
+
* @param config The reporter configuration options.
|
|
9
|
+
*/
|
|
27
10
|
export declare function attachFiles(testId: string, pwResult: PwTestResult, pulseResult: TestResult, config: PlaywrightPulseReporterOptions): void;
|
|
28
|
-
export {};
|
|
@@ -1,42 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.attachFiles = attachFiles;
|
|
4
|
-
const path =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
const fs = {
|
|
17
|
-
existsSync: (path) => {
|
|
18
|
-
console.log(`Checking if ${path} exists`);
|
|
19
|
-
return false;
|
|
20
|
-
},
|
|
21
|
-
mkdirSync: (path, options) => {
|
|
22
|
-
console.log(`Creating directory ${path}`);
|
|
23
|
-
},
|
|
24
|
-
readFileSync: (path, encoding) => {
|
|
25
|
-
console.log(`Reading file ${path}`);
|
|
26
|
-
return "";
|
|
27
|
-
},
|
|
28
|
-
copyFileSync: (src, dest) => {
|
|
29
|
-
console.log(`Copying ${src} to ${dest}`);
|
|
30
|
-
},
|
|
31
|
-
writeFileSync: (path, data) => {
|
|
32
|
-
console.log(`Writing to ${path}`);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
const ATTACHMENTS_SUBDIR = "attachments";
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("fs")); // Use synchronous methods for simplicity in this context
|
|
39
|
+
const ATTACHMENTS_SUBDIR = "attachments"; // Consistent subdirectory name
|
|
40
|
+
/**
|
|
41
|
+
* Processes attachments from a Playwright TestResult and updates the PulseTestResult.
|
|
42
|
+
* @param testId A unique identifier for the test, used for folder naming.
|
|
43
|
+
* @param pwResult The TestResult object from Playwright.
|
|
44
|
+
* @param pulseResult The internal test result structure to update.
|
|
45
|
+
* @param config The reporter configuration options.
|
|
46
|
+
*/
|
|
36
47
|
function attachFiles(testId, pwResult, pulseResult, config) {
|
|
37
48
|
const baseReportDir = config.outputDir || "pulse-report";
|
|
38
49
|
const attachmentsBaseDir = path.resolve(baseReportDir, ATTACHMENTS_SUBDIR);
|
|
39
|
-
const attachmentsSubFolder =
|
|
50
|
+
const attachmentsSubFolder = testId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
40
51
|
const testAttachmentsDir = path.join(attachmentsBaseDir, attachmentsSubFolder);
|
|
41
52
|
try {
|
|
42
53
|
if (!fs.existsSync(testAttachmentsDir)) {
|
|
@@ -50,6 +61,7 @@ function attachFiles(testId, pwResult, pulseResult, config) {
|
|
|
50
61
|
if (!pwResult.attachments)
|
|
51
62
|
return;
|
|
52
63
|
const { base64Images } = config;
|
|
64
|
+
// --- MODIFICATION: Initialize all attachment arrays to prevent errors ---
|
|
53
65
|
pulseResult.screenshots = [];
|
|
54
66
|
pulseResult.videoPath = [];
|
|
55
67
|
pulseResult.attachments = [];
|
|
@@ -79,10 +91,15 @@ function attachFiles(testId, pwResult, pulseResult, config) {
|
|
|
79
91
|
handleAttachment(attachmentPath, body, fullPath, relativePath, "tracePath", pulseResult, attachment);
|
|
80
92
|
}
|
|
81
93
|
else {
|
|
94
|
+
// --- MODIFICATION: Enabled handling for all other file types ---
|
|
82
95
|
handleAttachment(attachmentPath, body, fullPath, relativePath, "attachments", pulseResult, attachment);
|
|
83
96
|
}
|
|
84
97
|
});
|
|
85
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Handles image attachments, either embedding as base64 or copying the file.
|
|
101
|
+
* (This function is unchanged)
|
|
102
|
+
*/
|
|
86
103
|
function handleImage(attachmentPath, body, base64Embed, fullPath, relativePath, pulseResult, attachmentName) {
|
|
87
104
|
let screenshotData = undefined;
|
|
88
105
|
if (attachmentPath) {
|
|
@@ -118,7 +135,12 @@ function handleImage(attachmentPath, body, base64Embed, fullPath, relativePath,
|
|
|
118
135
|
pulseResult.screenshots.push(screenshotData);
|
|
119
136
|
}
|
|
120
137
|
}
|
|
121
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Handles non-image attachments by copying the file or writing the buffer.
|
|
140
|
+
*/
|
|
141
|
+
function handleAttachment(attachmentPath, body, fullPath, relativePath, resultKey, // MODIFIED: Added 'attachments'
|
|
142
|
+
pulseResult, originalAttachment // MODIFIED: Pass original attachment
|
|
143
|
+
) {
|
|
122
144
|
var _a, _b;
|
|
123
145
|
try {
|
|
124
146
|
if (attachmentPath) {
|
|
@@ -127,6 +149,7 @@ function handleAttachment(attachmentPath, body, fullPath, relativePath, resultKe
|
|
|
127
149
|
else if (body) {
|
|
128
150
|
fs.writeFileSync(fullPath, body);
|
|
129
151
|
}
|
|
152
|
+
// --- MODIFICATION: Logic to handle different properties correctly ---
|
|
130
153
|
switch (resultKey) {
|
|
131
154
|
case "videoPath":
|
|
132
155
|
(_a = pulseResult.videoPath) === null || _a === void 0 ? void 0 : _a.push(relativePath);
|
|
@@ -147,6 +170,11 @@ function handleAttachment(attachmentPath, body, fullPath, relativePath, resultKe
|
|
|
147
170
|
console.error(`Pulse Reporter: Failed to copy/write attachment to ${fullPath}. Error: ${error.message}`);
|
|
148
171
|
}
|
|
149
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Determines a file extension based on content type.
|
|
175
|
+
* @param contentType The MIME type string.
|
|
176
|
+
* @returns A file extension string.
|
|
177
|
+
*/
|
|
150
178
|
function getFileExtension(contentType) {
|
|
151
179
|
var _a;
|
|
152
180
|
if (!contentType)
|
package/dist/reporter/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { PlaywrightPulseReporter } from "./playwright-pulse-reporter";
|
|
2
2
|
export default PlaywrightPulseReporter;
|
|
3
3
|
export { PlaywrightPulseReporter };
|
|
4
|
+
export type { PlaywrightPulseReport } from "../lib/report-types";
|
|
5
|
+
export type { TestResult, TestRun, TestStep, TestStatus } from "../types";
|
package/dist/reporter/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlaywrightPulseReporter = void 0;
|
|
4
|
+
// src/reporter/index.ts
|
|
4
5
|
const playwright_pulse_reporter_1 = require("./playwright-pulse-reporter");
|
|
5
6
|
Object.defineProperty(exports, "PlaywrightPulseReporter", { enumerable: true, get: function () { return playwright_pulse_reporter_1.PlaywrightPulseReporter; } });
|
|
7
|
+
// Export the reporter class as the default export for CommonJS compatibility
|
|
8
|
+
// and also as a named export for potential ES module consumers.
|
|
6
9
|
exports.default = playwright_pulse_reporter_1.PlaywrightPulseReporter;
|
|
@@ -1,121 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
outputDir?: string;
|
|
4
|
-
shard?: {
|
|
5
|
-
current: number;
|
|
6
|
-
};
|
|
7
|
-
projects: Array<{
|
|
8
|
-
name?: string;
|
|
9
|
-
}>;
|
|
10
|
-
metadata?: any;
|
|
11
|
-
configFile?: string;
|
|
12
|
-
}
|
|
13
|
-
interface FullResult {
|
|
14
|
-
status: string;
|
|
15
|
-
duration: number;
|
|
16
|
-
}
|
|
17
|
-
interface Reporter {
|
|
18
|
-
onBegin?(config: FullConfig, suite: Suite): void;
|
|
19
|
-
onTestEnd?(test: TestCase, result: PwTestResult): void | Promise<void>;
|
|
20
|
-
onEnd?(result: FullResult): void | Promise<void>;
|
|
21
|
-
onError?(error: Error): void;
|
|
22
|
-
printsToStdio?(): boolean;
|
|
23
|
-
}
|
|
24
|
-
interface Suite {
|
|
25
|
-
}
|
|
26
|
-
interface TestCase {
|
|
27
|
-
id: string;
|
|
28
|
-
title: string;
|
|
29
|
-
tags: string[];
|
|
30
|
-
location?: {
|
|
31
|
-
file: string;
|
|
32
|
-
line: number;
|
|
33
|
-
column: number;
|
|
34
|
-
};
|
|
35
|
-
titlePath(): string[];
|
|
36
|
-
parent?: {
|
|
37
|
-
title?: string;
|
|
38
|
-
project?(): any;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
interface PwTestResult {
|
|
42
|
-
status: "passed" | "failed" | "timedOut" | "skipped" | "interrupted";
|
|
43
|
-
duration: number;
|
|
44
|
-
startTime: Date;
|
|
45
|
-
retry: number;
|
|
46
|
-
workerIndex: number;
|
|
47
|
-
stdout: Array<string | any>;
|
|
48
|
-
stderr: Array<string | any>;
|
|
49
|
-
error?: {
|
|
50
|
-
message?: string;
|
|
51
|
-
stack?: string;
|
|
52
|
-
snippet?: string;
|
|
53
|
-
};
|
|
54
|
-
steps: PwStep[];
|
|
55
|
-
attachments: Array<{
|
|
56
|
-
name: string;
|
|
57
|
-
contentType?: string;
|
|
58
|
-
path?: string;
|
|
59
|
-
body?: any;
|
|
60
|
-
}>;
|
|
61
|
-
}
|
|
62
|
-
interface PwStep {
|
|
63
|
-
title: string;
|
|
64
|
-
category: string;
|
|
65
|
-
startTime: Date;
|
|
66
|
-
duration: number;
|
|
67
|
-
error?: {
|
|
68
|
-
message?: string;
|
|
69
|
-
stack?: string;
|
|
70
|
-
snippet?: string;
|
|
71
|
-
};
|
|
72
|
-
count?: number;
|
|
73
|
-
location?: {
|
|
74
|
-
file: string;
|
|
75
|
-
line: number;
|
|
76
|
-
column: number;
|
|
77
|
-
};
|
|
78
|
-
steps?: PwStep[];
|
|
79
|
-
}
|
|
80
|
-
type PulseTestStatus = "passed" | "failed" | "skipped" | "flaky";
|
|
81
|
-
interface PulseTestStep {
|
|
82
|
-
title: string;
|
|
83
|
-
category: string;
|
|
84
|
-
startTime: Date;
|
|
85
|
-
duration: number;
|
|
86
|
-
error?: {
|
|
87
|
-
message: string;
|
|
88
|
-
stack?: string;
|
|
89
|
-
snippet?: string;
|
|
90
|
-
};
|
|
91
|
-
count: number;
|
|
92
|
-
location?: string;
|
|
93
|
-
status: PulseTestStatus;
|
|
94
|
-
}
|
|
95
|
-
interface PlaywrightPulseReporterOptions {
|
|
96
|
-
outputDir?: string;
|
|
97
|
-
outputFile?: string;
|
|
98
|
-
base64Images?: boolean;
|
|
99
|
-
open?: boolean;
|
|
100
|
-
resetOnEachRun?: boolean;
|
|
101
|
-
}
|
|
1
|
+
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult as PwTestResult } from "@playwright/test/reporter";
|
|
2
|
+
import type { PlaywrightPulseReporterOptions } from "../types";
|
|
102
3
|
export declare class PlaywrightPulseReporter implements Reporter {
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
107
|
-
private shardIndex?;
|
|
4
|
+
private config;
|
|
5
|
+
private suite;
|
|
6
|
+
private results;
|
|
7
|
+
private runStartTime;
|
|
108
8
|
private options;
|
|
9
|
+
private outputDir;
|
|
10
|
+
private attachmentsDir;
|
|
11
|
+
private baseOutputFile;
|
|
12
|
+
private isSharded;
|
|
13
|
+
private shardIndex;
|
|
14
|
+
private resetOnEachRun;
|
|
109
15
|
constructor(options?: PlaywrightPulseReporterOptions);
|
|
110
16
|
printsToStdio(): boolean;
|
|
111
17
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
112
|
-
|
|
113
|
-
|
|
18
|
+
onTestBegin(test: TestCase): void;
|
|
19
|
+
private getBrowserDetails;
|
|
20
|
+
private processStep;
|
|
114
21
|
onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
|
|
115
22
|
private _getFinalizedResults;
|
|
116
|
-
|
|
117
|
-
private _getSummaryStatsFromAttempts;
|
|
118
|
-
onError(error: Error): void;
|
|
23
|
+
onError(error: any): void;
|
|
119
24
|
private _getEnvDetails;
|
|
120
25
|
private _writeShardResults;
|
|
121
26
|
private _mergeShardResults;
|
|
@@ -124,4 +29,4 @@ export declare class PlaywrightPulseReporter implements Reporter {
|
|
|
124
29
|
onEnd(result: FullResult): Promise<void>;
|
|
125
30
|
private _mergeAllRunReports;
|
|
126
31
|
}
|
|
127
|
-
export
|
|
32
|
+
export default PlaywrightPulseReporter;
|