@arghajit/dummy 0.3.17 → 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/README.md CHANGED
@@ -10,7 +10,7 @@ _The ultimate Playwright reporter — Interactive dashboard with historical tren
10
10
 
11
11
  ## [Live Demo](https://arghajit47.github.io/playwright-pulse/demo.html)
12
12
 
13
- ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/features.svg)
13
+ ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/features.svg)
14
14
 
15
15
  ## **Documentation**: [Pulse Report](https://arghajit47.github.io/playwright-pulse/)
16
16
 
@@ -21,7 +21,7 @@ The project provides these utility commands:
21
21
  | Command | Description |
22
22
  |------------------------|-----------------------------------------------------------------------------|
23
23
  | `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 |
24
- | `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 |
24
+ | `generate-pulse-report`| Generates `playwright-pulse-static-report.html`, Self-contained, no server required, Preserves all dashboard functionality, all the attachments are embedded in the report, no need to have attachments/ directory when viewing the report, with a dark theme and better initial load handling |
25
25
  | `merge-pulse-report` | Combines multiple parallel test json reports, basically used in sharding |
26
26
  | `generate-trend` | Analyzes historical trends in test results |
27
27
  | `generate-email-report`| Generates email-friendly report versions |
@@ -101,24 +101,7 @@ npx merge-pulse-report --outputDir {YOUR_CUSTOM_REPORT_FOLDER}
101
101
 
102
102
  **Important:** Make sure your `playwright.config.ts` custom directory matches the CLI script:
103
103
 
104
- ```typescript
105
- import { defineConfig } from "@playwright/test";
106
- import * as path from "path";
107
-
108
- const CUSTOM_REPORT_DIR = path.resolve(__dirname, "{YOUR_CUSTOM_REPORT_FOLDER}");
109
-
110
- export default defineConfig({
111
- reporter: [
112
- ["list"],
113
- [
114
- "@arghajit/playwright-pulse-report",
115
- {
116
- outputDir: CUSTOM_REPORT_DIR, // Must match CLI --outputDir
117
- },
118
- ],
119
- ],
120
- });
121
- ```
104
+ ![Custom Output Directory](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/custom-output-directory-config.png)
122
105
 
123
106
  ## 📊 Report Options
124
107
 
@@ -240,76 +223,100 @@ Under the hood, this will:
240
223
  ### Basic Workflow
241
224
 
242
225
  ```yaml
243
- # Upload Pulse report from each shard (per matrix.config.type)
244
- - name: Upload Pulse Report results
245
- if: success() || failure()
246
- uses: actions/upload-artifact@v4
247
- with:
248
- name: pulse-report
249
- path: pulse-report/
250
-
251
- # Download all pulse-report-* artifacts after all shards complete
252
- - name: Download Pulse Report artifacts
253
- uses: actions/download-artifact@v4
254
- with:
255
- pattern: pulse-report
256
- path: downloaded-artifacts
257
-
258
- # Merge all sharded JSON reports into one final output
259
- - name: Generate Pulse Report
260
- run: |
261
- npm run script merge-report
262
- npm run generate-report [or, npm run generate-pulse-report]
263
-
264
- # Upload final merged report as CI artifact
265
- - name: Upload Pulse report
266
- uses: actions/upload-artifact@v4
267
- with:
268
- name: pulse-report
226
+ # .github/workflows/playwright.yml
227
+ name: Playwright Tests
228
+ on:
229
+ push:
230
+ branches: [ main, master ]
231
+ pull_request:
232
+ branches: [ main, master ]
233
+ jobs:
234
+ test:
235
+ timeout-minutes: 60
236
+ runs-on: ubuntu-latest
237
+ steps:
238
+ - uses: actions/checkout@v4
239
+ - uses: actions/setup-node@v4
240
+ with:
241
+ node-version: lts/*
242
+ - name: Install dependencies
243
+ run: npm ci
244
+ - name: Install Playwright Browsers
245
+ run: npx playwright install --with-deps
246
+ - name: Run Playwright tests
247
+ run: npm run test
248
+ - uses: actions/upload-artifact@v4
249
+ if: always()
250
+ with:
251
+ name: playwright-report
252
+ path: playwright-report/
253
+ retention-days: 30
269
254
  ```
270
255
 
256
+ For more details, please refer to the [Pulse Report Basic CI/CD Integration](https://arghajit47.github.io/playwright-pulse/advanced-usage.html).
257
+
271
258
  ### Sharded Workflow
272
259
 
273
260
  ```yaml
274
- # Upload Pulse report from each shard (per matrix.config.type)
275
- - name: Upload Pulse Report results
276
- if: success() || failure()
277
- uses: actions/upload-artifact@v4
278
- with:
279
- name: pulse-report-${{ matrix.config.type }}
280
- path: pulse-report/
281
-
282
- # Download all pulse-report-* artifacts after all shards complete
283
- - name: Download Pulse Report artifacts
284
- uses: actions/download-artifact@v4
285
- with:
286
- pattern: pulse-report-*
287
- path: downloaded-artifacts
288
-
289
- # Organize reports into a single folder and rename for merging
290
- - name: Organize Pulse Report
291
- run: |
292
- mkdir -p pulse-report
293
- for dir in downloaded-artifacts/pulse-report-*; do
294
- config_type=$(basename "$dir" | sed 's/pulse-report-//')
295
- cp -r "$dir/attachments" "pulse-report/attachments"
296
- cp "$dir/playwright-pulse-report.json" "pulse-report/playwright-pulse-report-${config_type}.json"
297
- done
298
-
299
- # Merge all sharded JSON reports into one final output
300
- - name: Generate Pulse Report
301
- run: |
302
- npm run merge-report
303
- npm run generate-report [or, npm run generate-pulse-report]
304
-
305
- # Upload final merged report as CI artifact
306
- - name: Upload Pulse report
307
- uses: actions/upload-artifact@v4
308
- with:
309
- name: pulse-report
310
- path: pulse-report/
261
+ # .github/workflows/playwright.yml
262
+ name: Playwright Tests with Pulse Report
263
+ on: [push]
264
+ jobs:
265
+ test:
266
+ timeout-minutes: 60
267
+ runs-on: ubuntu-latest
268
+ strategy:
269
+ fail-fast: false
270
+ matrix:
271
+ shard: [1, 2, 3, 4]
272
+ steps:
273
+ - uses: actions/checkout@v4
274
+ - uses: actions/setup-node@v4
275
+ with:
276
+ node-version: 18
277
+ - run: npm ci
278
+ - run: npx playwright install --with-deps
279
+ - run: npx playwright test --shard=${{ matrix.shard }}/${{ strategy.job-total }}
280
+ - uses: actions/upload-artifact@v4
281
+ if: always()
282
+ with:
283
+ name: pulse-report-shard-${{ matrix.shard }}
284
+ path: pulse-report/
285
+ retention-days: 1
286
+
287
+ merge-report:
288
+ needs: test
289
+ if: always()
290
+ runs-on: ubuntu-latest
291
+ steps:
292
+ - uses: actions/checkout@v4
293
+ - uses: actions/setup-node@v4
294
+ with:
295
+ node-version: 18
296
+ - run: npm ci
297
+
298
+ # Download all shard artifacts to a single directory
299
+ - uses: actions/download-artifact@v4
300
+ with:
301
+ path: all-reports
302
+ pattern: pulse-report-shard-*
303
+
304
+ # Merge all shard reports into a single report
305
+ - run: npx merge-pulse-report -o all-reports
306
+
307
+ # Generate the final HTML report
308
+ - run: npx generate-pulse-report -o all-reports
309
+
310
+ # Upload the final merged report
311
+ - uses: actions/upload-artifact@v4
312
+ with:
313
+ name: final-playwright-pulse-report
314
+ path: all-reports/
315
+ retention-days: 7
311
316
  ```
312
317
 
318
+ For more details, please refer to the [Pulse Report Sharded CI/CD Integration](https://arghajit47.github.io/playwright-pulse/sharding.html).
319
+
313
320
  ## 🧠 Notes
314
321
 
315
322
  - <strong>`npm run generate-report` generates a HTML report ( screenshots/images will be taken in realtime from 'attachments/' directory ).</strong>
@@ -319,13 +326,14 @@ Under the hood, this will:
319
326
  - After the test matrix completes, reports are downloaded, renamed, and merged.
320
327
  - merge-report is a custom Node.js script that combines all JSON files into one.
321
328
 
322
- ## ![Features](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images//pulse-folder-structures.svg)
329
+ ## ![Folder-Structure](https://ocpaxmghzmfbuhxzxzae.supabase.co/storage/v1/object/public/images/pulse-report/pulse-folder-structures.svg)
323
330
 
324
331
  ### 🚀 **Upgrade Now**
325
332
 
326
333
  ```bash
327
334
  npm install @arghajit/playwright-pulse-report@latest
328
335
  ```
336
+
329
337
  ---
330
338
 
331
339
  ## ⚙️ Advanced Configuration
@@ -340,7 +348,7 @@ npx playwright test test1.spec.ts && npx playwright test test2.spec.ts
340
348
 
341
349
  By default, In this above scenario, the report from test1 will be lost. To solve this, you can use the resetOnEachRun option.
342
350
 
343
- ```bash
351
+ ```javascript
344
352
  // playwright.config.ts
345
353
  import { defineConfig } from "@playwright/test";
346
354
  import * as path from "path";
@@ -17,6 +17,7 @@ export declare class PlaywrightPulseReporter implements Reporter {
17
17
  onBegin(config: FullConfig, suite: Suite): void;
18
18
  onTestBegin(test: TestCase): void;
19
19
  private _getSeverity;
20
+ private extractCodeSnippet;
20
21
  private getBrowserDetails;
21
22
  private processStep;
22
23
  onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
@@ -116,6 +116,35 @@ class PlaywrightPulseReporter {
116
116
  const severityAnnotation = annotations.find((a) => a.type === "pulse_severity");
117
117
  return (severityAnnotation === null || severityAnnotation === void 0 ? void 0 : severityAnnotation.description) || "Medium";
118
118
  }
119
+ async extractCodeSnippet(filePath, targetLine, targetColumn) {
120
+ try {
121
+ const fileContent = await fs.readFile(filePath, "utf-8");
122
+ const lines = fileContent.split("\n");
123
+ if (targetLine < 1 || targetLine > lines.length) {
124
+ return undefined;
125
+ }
126
+ const contextLines = 2;
127
+ const startLine = Math.max(0, targetLine - contextLines - 1);
128
+ const endLine = Math.min(lines.length, targetLine + contextLines);
129
+ const snippetLines = [];
130
+ for (let i = startLine; i < endLine; i++) {
131
+ const lineNum = i + 1;
132
+ const isTargetLine = lineNum === targetLine;
133
+ const lineContent = lines[i] || "";
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)) + "^";
138
+ snippetLines.push(pointer);
139
+ }
140
+ }
141
+ return snippetLines.length > 0 ? snippetLines.join("\n") : undefined;
142
+ }
143
+ catch (error) {
144
+ console.error(`Failed to extract code snippet from ${filePath}:${targetLine}:${targetColumn}`, error);
145
+ return undefined;
146
+ }
147
+ }
119
148
  getBrowserDetails(test) {
120
149
  var _a, _b, _c, _d;
121
150
  const project = (_a = test.parent) === null || _a === void 0 ? void 0 : _a.project();
@@ -180,8 +209,18 @@ class PlaywrightPulseReporter {
180
209
  const startTime = new Date(step.startTime);
181
210
  const endTime = new Date(startTime.getTime() + Math.max(0, duration));
182
211
  let codeLocation = "";
212
+ let codeSnippet = undefined;
183
213
  if (step.location) {
184
214
  codeLocation = `${path.relative(this.config.rootDir, step.location.file)}:${step.location.line}:${step.location.column}`;
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
+ }
185
224
  }
186
225
  return {
187
226
  id: `${testId}_step_${startTime.toISOString()}-${duration}-${(0, crypto_1.randomUUID)()}`,
@@ -194,6 +233,7 @@ class PlaywrightPulseReporter {
194
233
  errorMessage: errorMessage,
195
234
  stackTrace: ((_d = step.error) === null || _d === void 0 ? void 0 : _d.stack) || undefined,
196
235
  codeLocation: codeLocation || undefined,
236
+ codeSnippet: codeSnippet,
197
237
  isHook: step.category === "hook",
198
238
  hookType: step.category === "hook"
199
239
  ? step.title.toLowerCase().includes("before")
@@ -230,8 +270,7 @@ class PlaywrightPulseReporter {
230
270
  let codeSnippet = undefined;
231
271
  try {
232
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)) {
233
- const relativePath = path.relative(this.config.rootDir, test.location.file);
234
- 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);
235
274
  }
236
275
  }
237
276
  catch (e) {
@@ -11,6 +11,7 @@ export interface TestStep {
11
11
  errorMessage?: string;
12
12
  stackTrace?: string;
13
13
  codeLocation?: string;
14
+ codeSnippet?: string;
14
15
  isHook?: boolean;
15
16
  hookType?: "before" | "after";
16
17
  isFailedStep?: boolean;
@@ -68,7 +69,7 @@ export interface TestRun {
68
69
  failed: number;
69
70
  skipped: number;
70
71
  duration: number;
71
- environment?: EnvDetails;
72
+ environment?: EnvDetails | EnvDetails[];
72
73
  }
73
74
  export interface TrendDataPoint {
74
75
  date: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arghajit/dummy",
3
3
  "author": "Arghajit Singha",
4
- "version": "0.3.17",
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
  ".": {
@@ -87,6 +89,8 @@
87
89
  "@playwright/test": ">=1.40.0"
88
90
  },
89
91
  "overrides": {
90
- "glob": "^13.0.0"
92
+ "glob": "^13.0.0",
93
+ "minimatch": "^10.1.2",
94
+ "@isaacs/brace-expansion": "^5.0.1"
91
95
  }
92
96
  }
@@ -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
- `🎉 Minified Pulse summary report generated successfully at: ${minifiedReportHtmlPath}`
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) {