@reportforge/playwright-pdf 0.0.1
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/CHANGELOG.md +285 -0
- package/LICENSE +21 -0
- package/README.md +524 -0
- package/ci-templates/azure-devops/azure-pipelines.yml +58 -0
- package/ci-templates/bitbucket/bitbucket-pipelines.yml +42 -0
- package/ci-templates/github-actions/basic-workflow.yml +44 -0
- package/ci-templates/github-actions/matrix-workflow.yml +69 -0
- package/ci-templates/gitlab-ci/.gitlab-ci.yml +42 -0
- package/ci-templates/jenkins/Jenkinsfile +54 -0
- package/dist/index.d.mts +272 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +12566 -0
- package/dist/index.mjs +12567 -0
- package/dist/templates/layouts/detailed.hbs +38 -0
- package/dist/templates/layouts/executive.hbs +35 -0
- package/dist/templates/layouts/minimal.hbs +29 -0
- package/dist/templates/partials/charts.hbs +306 -0
- package/dist/templates/partials/ci-environment.hbs +56 -0
- package/dist/templates/partials/cover-page.hbs +46 -0
- package/dist/templates/partials/defect-log.hbs +27 -0
- package/dist/templates/partials/executive-summary.hbs +60 -0
- package/dist/templates/partials/failure-deep-dive.hbs +61 -0
- package/dist/templates/partials/head.hbs +17 -0
- package/dist/templates/partials/release-gate.hbs +63 -0
- package/dist/templates/partials/requirements-matrix.hbs +35 -0
- package/dist/templates/partials/slow-tests.hbs +27 -0
- package/dist/templates/partials/suite-breakdown.hbs +58 -0
- package/dist/templates/partials/watermark.hbs +3 -0
- package/dist/templates/styles/base.css +234 -0
- package/dist/templates/styles/detailed.css +311 -0
- package/dist/templates/styles/executive.css +334 -0
- package/dist/templates/styles/minimal.css +208 -0
- package/package.json +99 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
|
2
|
+
|
|
3
|
+
type TemplateId = 'minimal' | 'detailed' | 'executive';
|
|
4
|
+
/**
|
|
5
|
+
* License plan. Subscription is the only product — every active license is the
|
|
6
|
+
* same plan. The "no license" case is represented by the absence of a
|
|
7
|
+
* LicenseInfo (LicenseClient.resolve() returns null), not by a sentinel plan.
|
|
8
|
+
*/
|
|
9
|
+
type LicensePlan = 'subscription';
|
|
10
|
+
interface ReporterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Output file path. Supports tokens: {date}, {branch}, {status}.
|
|
13
|
+
* @default 'playwright-report/{date}-report.pdf'
|
|
14
|
+
*/
|
|
15
|
+
outputFile?: string;
|
|
16
|
+
/**
|
|
17
|
+
* PDF report template(s) to use. Pass a single string or an array to
|
|
18
|
+
* generate multiple PDFs in one run. When an array is given, the template
|
|
19
|
+
* name is appended to each output filename automatically:
|
|
20
|
+
* outputFile: 'reports/{date}-report.pdf'
|
|
21
|
+
* template: ['detailed', 'executive']
|
|
22
|
+
* → reports/2026-04-28-report-detailed.pdf
|
|
23
|
+
* reports/2026-04-28-report-executive.pdf
|
|
24
|
+
*
|
|
25
|
+
* - minimal: clean white layout, developer-focused, fast
|
|
26
|
+
* - detailed: full QA report with defect log and requirements traceability
|
|
27
|
+
* - executive: cover page, KPI dashboard, charts for stakeholders
|
|
28
|
+
* @default 'minimal'
|
|
29
|
+
*/
|
|
30
|
+
template?: TemplateId | TemplateId[];
|
|
31
|
+
/**
|
|
32
|
+
* ReportForge license key. Falls back to RF_LICENSE_KEY environment variable.
|
|
33
|
+
* If omitted (or invalid / inactive), the reporter logs a warning and skips
|
|
34
|
+
* PDF generation — your Playwright tests still run normally.
|
|
35
|
+
*/
|
|
36
|
+
licenseKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Path to a logo image (PNG, JPG, or SVG) to embed in the report header.
|
|
39
|
+
* Supports both absolute and relative paths.
|
|
40
|
+
*/
|
|
41
|
+
logo?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Primary brand colour (hex). Used for headers and accent bars.
|
|
44
|
+
* @default '#CC785C'
|
|
45
|
+
*/
|
|
46
|
+
primaryColor?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Accent brand colour (hex). Used for highlights and badges.
|
|
49
|
+
* @default '#3F7D58'
|
|
50
|
+
*/
|
|
51
|
+
accentColor?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Text to render as a diagonal watermark overlay on every page.
|
|
54
|
+
* Example: 'CONFIDENTIAL', 'DRAFT'
|
|
55
|
+
*/
|
|
56
|
+
watermark?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Password to protect the generated PDF (Enterprise tier).
|
|
59
|
+
* Requires qpdf to be installed on the system.
|
|
60
|
+
*/
|
|
61
|
+
pdfPassword?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Custom title for the report cover and header.
|
|
64
|
+
* @default 'Playwright Test Report'
|
|
65
|
+
*/
|
|
66
|
+
reportTitle?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Project or application name. Inferred from package.json if absent.
|
|
69
|
+
*/
|
|
70
|
+
projectName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Open the generated PDF automatically after generation (local use only).
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
open?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Full path to a Chrome/Chromium executable.
|
|
78
|
+
* Falls back to PUPPETEER_EXECUTABLE_PATH env, then system Chrome discovery.
|
|
79
|
+
*/
|
|
80
|
+
puppeteerExecutablePath?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Base URL for the ReportForge licensing server. Overrides the default
|
|
83
|
+
* (https://reportforge.org) during local development and tests.
|
|
84
|
+
* Also configurable via REPORTFORGE_SERVER_URL env var.
|
|
85
|
+
*/
|
|
86
|
+
serverUrl?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Compression preset for screenshots embedded into the PDF.
|
|
89
|
+
* - 'auto' — picks based on test / failure volume (default)
|
|
90
|
+
* - 'none' — pass-through (original PNG, largest)
|
|
91
|
+
* - 'balanced' — JPEG q85, max 1400px wide
|
|
92
|
+
* - 'max' — JPEG q70, max 1000px wide (smallest)
|
|
93
|
+
* @default 'auto'
|
|
94
|
+
*/
|
|
95
|
+
compressionLevel?: 'auto' | 'none' | 'balanced' | 'max';
|
|
96
|
+
/**
|
|
97
|
+
* Whether to embed Playwright screenshots into the PDF.
|
|
98
|
+
* When false, failure entries still appear (title, error, stack trace)
|
|
99
|
+
* but without screenshot images — useful for exec-audience reports or
|
|
100
|
+
* reducing file size when visual evidence is not needed.
|
|
101
|
+
* Applies to all three templates.
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
104
|
+
includeScreenshots?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Maximum number of failure entries rendered inline in the PDF.
|
|
107
|
+
* Overflow is written to a sibling `{basename}-failures.json` sidecar file
|
|
108
|
+
* and a banner is shown above the failures section. If omitted, the cap
|
|
109
|
+
* is derived from `compressionLevel`.
|
|
110
|
+
*/
|
|
111
|
+
maxInlineFailures?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Soft cap on final PDF size in megabytes. If the generated PDF exceeds
|
|
114
|
+
* this, the report is re-rendered once with the 'max' compression preset.
|
|
115
|
+
* Set to 0 to disable the cap. Defaults to 8 MB (email-friendly).
|
|
116
|
+
* @default 8
|
|
117
|
+
*/
|
|
118
|
+
maxFileSizeMb?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Merge N Playwright JSON shard report files into a single PDF.
|
|
121
|
+
* Accepts a path/glob string or an array of paths/globs.
|
|
122
|
+
*
|
|
123
|
+
* Workflow:
|
|
124
|
+
* 1. Run each shard with `--reporter=json` to produce JSON output files.
|
|
125
|
+
* 2. After all shards finish, run a Playwright invocation with this reporter
|
|
126
|
+
* configured and `shardResults` pointing at the JSON files — the live run
|
|
127
|
+
* may have zero tests.
|
|
128
|
+
*
|
|
129
|
+
* Known limitation: timed-out tests are counted as failures in shard mode
|
|
130
|
+
* (Playwright JSON stats do not distinguish timedOut from failed).
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* shardResults: 'results/shard-*.json'
|
|
134
|
+
* @example
|
|
135
|
+
* shardResults: ['results/shard-1.json', 'results/shard-2.json']
|
|
136
|
+
*/
|
|
137
|
+
shardResults?: string | string[];
|
|
138
|
+
/**
|
|
139
|
+
* Webhook notification channels. Post a pass/fail summary after each run.
|
|
140
|
+
* Each channel must have `enabled: true` to fire (default is `false`).
|
|
141
|
+
* `on` controls the trigger: `'always'` (default), `'failure'`, or `'success'`.
|
|
142
|
+
*/
|
|
143
|
+
notify?: {
|
|
144
|
+
slack?: {
|
|
145
|
+
url: string;
|
|
146
|
+
on?: 'always' | 'failure' | 'success';
|
|
147
|
+
enabled?: boolean;
|
|
148
|
+
};
|
|
149
|
+
teams?: {
|
|
150
|
+
url: string;
|
|
151
|
+
on?: 'always' | 'failure' | 'success';
|
|
152
|
+
enabled?: boolean;
|
|
153
|
+
};
|
|
154
|
+
discord?: {
|
|
155
|
+
url: string;
|
|
156
|
+
on?: 'always' | 'failure' | 'success';
|
|
157
|
+
enabled?: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Path to the history JSON file. Defaults to
|
|
162
|
+
* `~/.reportforge/{projectKey}/history.json` where `projectKey` is derived
|
|
163
|
+
* from the raw `outputFile` string. Set explicitly to share history across
|
|
164
|
+
* machines or to place the file inside the repo (e.g. `.reportforge/history.json`).
|
|
165
|
+
*/
|
|
166
|
+
historyFile?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Maximum number of runs to keep in the history file. Older runs are pruned
|
|
169
|
+
* on append.
|
|
170
|
+
* @default 10
|
|
171
|
+
*/
|
|
172
|
+
historySize?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Show the pass-rate sparkline and delta badge in the `detailed` template.
|
|
175
|
+
* Set to `false` to disable history tracking entirely.
|
|
176
|
+
* @default true
|
|
177
|
+
*/
|
|
178
|
+
showTrend?: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The resolved license for the current reporter run.
|
|
183
|
+
*
|
|
184
|
+
* The mere existence of a LicenseInfo means the subscription is active —
|
|
185
|
+
* "no license" is represented by `LicenseClient.resolve()` returning null,
|
|
186
|
+
* not by a sentinel plan or `valid: false` flag.
|
|
187
|
+
*
|
|
188
|
+
* `source` surfaces how the license was obtained so the reporter can log
|
|
189
|
+
* actionable diagnostics:
|
|
190
|
+
* - 'jwt-online' → freshly activated/refreshed against the server
|
|
191
|
+
* - 'jwt-cache' → served from ~/.reportforge/license.json (offline)
|
|
192
|
+
*/
|
|
193
|
+
interface LicenseInfo {
|
|
194
|
+
plan: LicensePlan;
|
|
195
|
+
source: 'jwt-online' | 'jwt-cache';
|
|
196
|
+
expiry: Date;
|
|
197
|
+
key: string;
|
|
198
|
+
machinesUsed?: number;
|
|
199
|
+
machineLimit?: number;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* PdfReporter — Playwright custom reporter that generates professional PDF reports.
|
|
204
|
+
*
|
|
205
|
+
* Usage in playwright.config.ts:
|
|
206
|
+
* ```ts
|
|
207
|
+
* reporter: [
|
|
208
|
+
* ['@reportforge/playwright-pdf', {
|
|
209
|
+
* template: 'detailed',
|
|
210
|
+
* outputFile: 'reports/{date}-{branch}-report.pdf',
|
|
211
|
+
* logo: './assets/logo.png',
|
|
212
|
+
* primaryColor: '#CC785C',
|
|
213
|
+
* }]
|
|
214
|
+
* ]
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* The reporter automatically reads `RF_LICENSE_KEY` from the environment.
|
|
218
|
+
* You can also pass it explicitly via the `licenseKey` option — useful when
|
|
219
|
+
* the key comes from a non-standard source.
|
|
220
|
+
*
|
|
221
|
+
* Pass an array to generate one PDF per template in a single run:
|
|
222
|
+
* ```ts
|
|
223
|
+
* reporter: [
|
|
224
|
+
* ['@reportforge/playwright-pdf', {
|
|
225
|
+
* template: ['detailed', 'executive'],
|
|
226
|
+
* outputFile: 'reports/{date}-report.pdf',
|
|
227
|
+
* }]
|
|
228
|
+
* ]
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* An active ReportForge subscription is required. Without a valid license the
|
|
232
|
+
* reporter logs a single-line warning and skips PDF generation — your
|
|
233
|
+
* Playwright tests still run normally.
|
|
234
|
+
*/
|
|
235
|
+
declare class PdfReporter implements Reporter {
|
|
236
|
+
private readonly options;
|
|
237
|
+
private readonly cwd;
|
|
238
|
+
private readonly licenseClient;
|
|
239
|
+
private readonly dataCollector;
|
|
240
|
+
private readonly pdfGenerator;
|
|
241
|
+
constructor(rawOptions?: ReporterOptions);
|
|
242
|
+
onBegin(config: FullConfig, suite: Suite): void;
|
|
243
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
244
|
+
onEnd(result: FullResult): Promise<void>;
|
|
245
|
+
private _collectData;
|
|
246
|
+
private _appendTrend;
|
|
247
|
+
private _buildReportData;
|
|
248
|
+
printsToStdio(): boolean;
|
|
249
|
+
private resolveLicense;
|
|
250
|
+
private resolveProjectName;
|
|
251
|
+
private openPdf;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Returns the options object unchanged, but typed as `ReporterOptions`.
|
|
256
|
+
* Use this in `playwright.config.ts` to get full IntelliSense on all
|
|
257
|
+
* reporter properties:
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { defineReporterConfig } from '@reportforge/playwright-pdf';
|
|
261
|
+
*
|
|
262
|
+
* reporter: [
|
|
263
|
+
* ['@reportforge/playwright-pdf', defineReporterConfig({
|
|
264
|
+
* template: 'detailed',
|
|
265
|
+
* outputFile: 'reports/{date}-report.pdf',
|
|
266
|
+
* })]
|
|
267
|
+
* ]
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare function defineReporterConfig(options: ReporterOptions): ReporterOptions;
|
|
271
|
+
|
|
272
|
+
export { type LicenseInfo, type LicensePlan, PdfReporter, type ReporterOptions, type TemplateId, PdfReporter as default, defineReporterConfig };
|