@arghajit/dummy 0.3.18 ā 0.3.19
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/dist/reporter/playwright-pulse-reporter.js +20 -8
- package/package.json +4 -2
- package/scripts/generate-email-report.mjs +5 -2
- package/scripts/generate-report.mjs +4 -1
- package/scripts/generate-static-report.mjs +4 -1
- package/scripts/merge-pulse-report.js +3 -0
- package/scripts/sendReport.mjs +3 -0
- package/scripts/terminal-logo.mjs +51 -0
|
@@ -120,7 +120,10 @@ class PlaywrightPulseReporter {
|
|
|
120
120
|
try {
|
|
121
121
|
const fileContent = await fs.readFile(filePath, "utf-8");
|
|
122
122
|
const lines = fileContent.split("\n");
|
|
123
|
-
|
|
123
|
+
if (targetLine < 1 || targetLine > lines.length) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const contextLines = 2;
|
|
124
127
|
const startLine = Math.max(0, targetLine - contextLines - 1);
|
|
125
128
|
const endLine = Math.min(lines.length, targetLine + contextLines);
|
|
126
129
|
const snippetLines = [];
|
|
@@ -128,15 +131,17 @@ class PlaywrightPulseReporter {
|
|
|
128
131
|
const lineNum = i + 1;
|
|
129
132
|
const isTargetLine = lineNum === targetLine;
|
|
130
133
|
const lineContent = lines[i] || "";
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
const prefix = isTargetLine ? ">" : " ";
|
|
135
|
+
snippetLines.push(`${prefix} ${lineNum.toString().padStart(4)} | ${lineContent}`);
|
|
136
|
+
if (isTargetLine && targetColumn > 0) {
|
|
137
|
+
const pointer = " " + " ".repeat(4) + " | " + " ".repeat(Math.max(0, targetColumn)) + "^";
|
|
134
138
|
snippetLines.push(pointer);
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
|
-
return snippetLines.join("\n");
|
|
141
|
+
return snippetLines.length > 0 ? snippetLines.join("\n") : undefined;
|
|
138
142
|
}
|
|
139
143
|
catch (error) {
|
|
144
|
+
console.error(`Failed to extract code snippet from ${filePath}:${targetLine}:${targetColumn}`, error);
|
|
140
145
|
return undefined;
|
|
141
146
|
}
|
|
142
147
|
}
|
|
@@ -207,7 +212,15 @@ class PlaywrightPulseReporter {
|
|
|
207
212
|
let codeSnippet = undefined;
|
|
208
213
|
if (step.location) {
|
|
209
214
|
codeLocation = `${path.relative(this.config.rootDir, step.location.file)}:${step.location.line}:${step.location.column}`;
|
|
210
|
-
|
|
215
|
+
try {
|
|
216
|
+
codeSnippet = await this.extractCodeSnippet(step.location.file, step.location.line, step.location.column);
|
|
217
|
+
if (!codeSnippet) {
|
|
218
|
+
console.warn(`Pulse Reporter: extractCodeSnippet returned undefined for step "${step.title}" at ${step.location.file}:${step.location.line}:${step.location.column}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.error(`Pulse Reporter: Failed to extract code snippet for step "${step.title}":`, error);
|
|
223
|
+
}
|
|
211
224
|
}
|
|
212
225
|
return {
|
|
213
226
|
id: `${testId}_step_${startTime.toISOString()}-${duration}-${(0, crypto_1.randomUUID)()}`,
|
|
@@ -257,8 +270,7 @@ class PlaywrightPulseReporter {
|
|
|
257
270
|
let codeSnippet = undefined;
|
|
258
271
|
try {
|
|
259
272
|
if (((_b = test.location) === null || _b === void 0 ? void 0 : _b.file) && ((_c = test.location) === null || _c === void 0 ? void 0 : _c.line) && ((_d = test.location) === null || _d === void 0 ? void 0 : _d.column)) {
|
|
260
|
-
|
|
261
|
-
codeSnippet = `Test defined at: ${relativePath}:${test.location.line}:${test.location.column}`;
|
|
273
|
+
codeSnippet = await this.extractCodeSnippet(test.location.file, test.location.line, test.location.column);
|
|
262
274
|
}
|
|
263
275
|
}
|
|
264
276
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arghajit/dummy",
|
|
3
3
|
"author": "Arghajit Singha",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.19",
|
|
5
5
|
"description": "A Playwright reporter and dashboard for visualizing test results.",
|
|
6
6
|
"homepage": "https://arghajit47.github.io/playwright-pulse/",
|
|
7
7
|
"repository": {
|
|
@@ -34,12 +34,14 @@
|
|
|
34
34
|
],
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"bin": {
|
|
37
|
+
"logo": "node scripts/terminal-logo.mjs",
|
|
37
38
|
"generate-pulse-report": "scripts/generate-static-report.mjs",
|
|
38
39
|
"generate-report": "scripts/generate-report.mjs",
|
|
39
40
|
"merge-pulse-report": "scripts/merge-pulse-report.js",
|
|
40
41
|
"send-email": "scripts/sendReport.mjs",
|
|
41
42
|
"generate-trend": "scripts/generate-trend.mjs",
|
|
42
|
-
"generate-email-report": "scripts/generate-email-report.mjs"
|
|
43
|
+
"generate-email-report": "scripts/generate-email-report.mjs",
|
|
44
|
+
"pulse-logo": "scripts/terminal-logo.mjs"
|
|
43
45
|
},
|
|
44
46
|
"exports": {
|
|
45
47
|
".": {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as fs from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { getOutputDir } from "./config-reader.mjs";
|
|
6
|
+
import { animate } from "./terminal-logo.mjs";
|
|
6
7
|
|
|
7
8
|
// Use dynamic import for chalk as it's ESM only
|
|
8
9
|
let chalk;
|
|
@@ -712,6 +713,8 @@ function generateMinifiedHTML(reportData) {
|
|
|
712
713
|
`;
|
|
713
714
|
}
|
|
714
715
|
async function main() {
|
|
716
|
+
await animate();
|
|
717
|
+
|
|
715
718
|
const outputDir = await getOutputDir(customOutputDir);
|
|
716
719
|
const reportJsonPath = path.resolve(outputDir, DEFAULT_JSON_FILE);
|
|
717
720
|
const minifiedReportHtmlPath = path.resolve(outputDir, MINIFIED_HTML_FILE); // Path for the new minified HTML
|
|
@@ -763,8 +766,8 @@ async function main() {
|
|
|
763
766
|
await fs.writeFile(minifiedReportHtmlPath, htmlContent, "utf-8");
|
|
764
767
|
console.log(
|
|
765
768
|
chalk.green.bold(
|
|
766
|
-
|
|
767
|
-
)
|
|
769
|
+
`Minified Pulse summary report generated successfully at: ${minifiedReportHtmlPath}`,
|
|
770
|
+
),
|
|
768
771
|
);
|
|
769
772
|
console.log(chalk.gray(`(This HTML file is designed to be lightweight)`));
|
|
770
773
|
} catch (error) {
|
|
@@ -6,6 +6,7 @@ import path from "path";
|
|
|
6
6
|
import { fork } from "child_process";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import { getOutputDir } from "./config-reader.mjs";
|
|
9
|
+
import { animate } from "./terminal-logo.mjs";
|
|
9
10
|
|
|
10
11
|
// Use dynamic import for chalk as it's ESM only
|
|
11
12
|
let chalk;
|
|
@@ -4822,6 +4823,8 @@ async function runScript(scriptPath, args = []) {
|
|
|
4822
4823
|
});
|
|
4823
4824
|
}
|
|
4824
4825
|
async function main() {
|
|
4826
|
+
await animate();
|
|
4827
|
+
|
|
4825
4828
|
const __filename = fileURLToPath(import.meta.url);
|
|
4826
4829
|
const __dirname = path.dirname(__filename);
|
|
4827
4830
|
|
|
@@ -5013,7 +5016,7 @@ async function main() {
|
|
|
5013
5016
|
await fs.writeFile(reportHtmlPath, htmlContent, "utf-8");
|
|
5014
5017
|
console.log(
|
|
5015
5018
|
chalk.green.bold(
|
|
5016
|
-
|
|
5019
|
+
`Pulse report generated successfully at: ${reportHtmlPath}`,
|
|
5017
5020
|
),
|
|
5018
5021
|
);
|
|
5019
5022
|
console.log(chalk.gray(`(You can open this file in your browser)`));
|
|
@@ -6,6 +6,7 @@ import path from "path";
|
|
|
6
6
|
import { fork } from "child_process";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import { getOutputDir } from "./config-reader.mjs";
|
|
9
|
+
import { animate } from "./terminal-logo.mjs";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Dynamically imports the 'chalk' library for terminal string styling.
|
|
@@ -6643,6 +6644,8 @@ async function runScript(scriptPath, args = []) {
|
|
|
6643
6644
|
* prepares the data, and then generates and writes the final HTML report file.
|
|
6644
6645
|
*/
|
|
6645
6646
|
async function main() {
|
|
6647
|
+
await animate();
|
|
6648
|
+
|
|
6646
6649
|
const __filename = fileURLToPath(import.meta.url);
|
|
6647
6650
|
const __dirname = path.dirname(__filename);
|
|
6648
6651
|
|
|
@@ -6837,7 +6840,7 @@ async function main() {
|
|
|
6837
6840
|
await fs.writeFile(reportHtmlPath, htmlContent, "utf-8");
|
|
6838
6841
|
console.log(
|
|
6839
6842
|
chalk.green.bold(
|
|
6840
|
-
|
|
6843
|
+
`Pulse report generated successfully at: ${reportHtmlPath}`,
|
|
6841
6844
|
),
|
|
6842
6845
|
);
|
|
6843
6846
|
console.log(chalk.gray(`(You can open this file in your browser)`));
|
|
@@ -180,6 +180,9 @@ function cleanupShardDirectories(shardDirs) {
|
|
|
180
180
|
|
|
181
181
|
// Main execution
|
|
182
182
|
(async () => {
|
|
183
|
+
const { animate } = await import("./terminal-logo.mjs");
|
|
184
|
+
await animate();
|
|
185
|
+
|
|
183
186
|
const REPORT_DIR = await getReportDir();
|
|
184
187
|
|
|
185
188
|
console.log(`\nš Playwright Pulse - Merge Reports (Sharding Mode)\n`);
|
package/scripts/sendReport.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
existsSync as fsExistsSync, // Renamed
|
|
9
9
|
} from "fs"; // CHANGED for specific functions
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
|
+
import { animate } from "./terminal-logo.mjs";
|
|
11
12
|
import { fork } from "child_process"; // This was missing in your sendReport.js but present in generate-email-report.js and needed for runScript
|
|
12
13
|
import "dotenv/config"; // CHANGED for dotenv
|
|
13
14
|
import { getOutputDir } from "./config-reader.mjs";
|
|
@@ -485,6 +486,8 @@ async function fetchCredentials(reportDir, retries = 10) {
|
|
|
485
486
|
}
|
|
486
487
|
|
|
487
488
|
const main = async () => {
|
|
489
|
+
await animate();
|
|
490
|
+
|
|
488
491
|
// Ensure fetch is initialized (dynamic import at top or here)
|
|
489
492
|
if (!fetch) {
|
|
490
493
|
try {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
const logoRaw = ` :------------
|
|
5
|
+
--------------------
|
|
6
|
+
-- ------------------------
|
|
7
|
+
------ ----------------
|
|
8
|
+
----- -------------
|
|
9
|
+
------ ----------- ---------
|
|
10
|
+
------- -------- ------ ---------
|
|
11
|
+
------------- ---- ---- --- -----------
|
|
12
|
+
----------- --- ---- ----- ------------
|
|
13
|
+
---------- ------- --------------
|
|
14
|
+
---------------- ----------- -----
|
|
15
|
+
----- ----------- -----
|
|
16
|
+
------------- ------
|
|
17
|
+
-------------------------------
|
|
18
|
+
--------------------
|
|
19
|
+
--------------`;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Plays the Pulse Logo animation.
|
|
23
|
+
* Exported so it can be triggered by other scripts in your bin configuration.
|
|
24
|
+
*/
|
|
25
|
+
export async function animate() {
|
|
26
|
+
// Just display the logo once without animation
|
|
27
|
+
// Terminal clearing doesn't work reliably across all environments
|
|
28
|
+
console.log(""); // Empty line for spacing
|
|
29
|
+
console.log(
|
|
30
|
+
logoRaw
|
|
31
|
+
.split("\n")
|
|
32
|
+
.map((line) => chalk.hex("#3f51b5")(line))
|
|
33
|
+
.join("\n"),
|
|
34
|
+
);
|
|
35
|
+
console.log(
|
|
36
|
+
chalk.white.bold(" P L A Y W R I G H T P U L S E R E P O R T"),
|
|
37
|
+
);
|
|
38
|
+
console.log(
|
|
39
|
+
chalk.gray(" āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā"),
|
|
40
|
+
);
|
|
41
|
+
console.log(""); // Empty line after logo
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Check if the script is being run directly (e.g., `pulse-logo`)
|
|
45
|
+
const isDirectRun =
|
|
46
|
+
import.meta.url === `file://${process.argv[1]}` ||
|
|
47
|
+
process.argv[1]?.endsWith("terminal-logo.mjs");
|
|
48
|
+
|
|
49
|
+
if (isDirectRun) {
|
|
50
|
+
animate();
|
|
51
|
+
}
|