@checkly/playwright-reporter 0.1.5 → 0.1.7
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/index.d.ts +213 -0
- package/dist/index.js +1036 -1
- package/package.json +15 -30
- package/README.md +0 -256
- package/dist/asset-collector.js +0 -1
- package/dist/clients/checkly-client.js +0 -1
- package/dist/clients/errors.js +0 -1
- package/dist/clients/index.js +0 -1
- package/dist/clients/test-results.js +0 -1
- package/dist/clients/types.js +0 -1
- package/dist/reporter.js +0 -1
- package/dist/types.js +0 -1
- package/dist/zipper.js +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export { Asset, AssetCollector, ZipEntry, ZipResult, Zipper, ZipperOptions } from '@checkly/reporter-utils';
|
|
2
|
+
import { FullConfig, Suite, JSONReport as JSONReport$1, JSONReportSuite as JSONReportSuite$1, JSONReportSpec as JSONReportSpec$1, JSONReportTest as JSONReportTest$1, JSONReportTestResult as JSONReportTestResult$1, Reporter, TestCase, TestResult, TestError } from '@playwright/test/reporter';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checkly environment for API endpoints
|
|
6
|
+
*/
|
|
7
|
+
type ChecklyEnvironment = 'local' | 'development' | 'staging' | 'production';
|
|
8
|
+
/**
|
|
9
|
+
* Context passed to sessionName callback function
|
|
10
|
+
*/
|
|
11
|
+
interface SessionNameContext {
|
|
12
|
+
/**
|
|
13
|
+
* The directory name where tests are running
|
|
14
|
+
*/
|
|
15
|
+
directoryName: string;
|
|
16
|
+
/**
|
|
17
|
+
* Playwright's full configuration object
|
|
18
|
+
*/
|
|
19
|
+
config: FullConfig;
|
|
20
|
+
/**
|
|
21
|
+
* The root test suite containing all tests
|
|
22
|
+
*/
|
|
23
|
+
suite: Suite;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Session name can be a static string or a function that returns a string
|
|
27
|
+
*/
|
|
28
|
+
type SessionNameOption = string | ((context: SessionNameContext) => string);
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for ChecklyReporter
|
|
31
|
+
*/
|
|
32
|
+
interface ChecklyReporterOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Checkly account ID for uploading test results
|
|
35
|
+
* Required for Phase 2 (upload functionality)
|
|
36
|
+
*/
|
|
37
|
+
accountId?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Checkly API key for authentication
|
|
40
|
+
* Required for Phase 2 (upload functionality)
|
|
41
|
+
*/
|
|
42
|
+
apiKey?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Checkly environment to use
|
|
45
|
+
* Can also be set via CHECKLY_ENV environment variable
|
|
46
|
+
* @default 'production'
|
|
47
|
+
*/
|
|
48
|
+
environment?: ChecklyEnvironment;
|
|
49
|
+
/**
|
|
50
|
+
* Output path for the generated ZIP file (for testing/debugging)
|
|
51
|
+
* @default 'checkly-report.zip'
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
outputPath?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Path to the JSON report file generated by Playwright's json reporter
|
|
57
|
+
* @default 'test-results/playwright-test-report.json'
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
jsonReportPath?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Directory containing test results and assets
|
|
63
|
+
* @default 'test-results'
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
testResultsDir?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Dry run mode - skips API calls and only creates local ZIP file
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
dryRun?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Custom name for the test session
|
|
74
|
+
* Can be a string or a callback function for dynamic names
|
|
75
|
+
* @default 'Playwright Test Session: {directoryName}'
|
|
76
|
+
* @example
|
|
77
|
+
* // Static string
|
|
78
|
+
* sessionName: 'My E2E Tests'
|
|
79
|
+
*
|
|
80
|
+
* // Dynamic with callback
|
|
81
|
+
* sessionName: ({ directoryName, config }) => `E2E: ${directoryName} (${config.projects.length} projects)`
|
|
82
|
+
*/
|
|
83
|
+
sessionName?: SessionNameOption;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Warning types that can be attached to test results
|
|
87
|
+
*/
|
|
88
|
+
type ChecklyWarningType = 'trace-off' | 'trace-retained-on-failure' | 'trace-first-retry-only' | 'trace-retries-only' | 'trace-retained-on-first-failure' | 'trace-missing';
|
|
89
|
+
/**
|
|
90
|
+
* A warning attached to a test result
|
|
91
|
+
*/
|
|
92
|
+
interface ChecklyWarning {
|
|
93
|
+
/**
|
|
94
|
+
* Type of warning for programmatic handling
|
|
95
|
+
*/
|
|
96
|
+
type: ChecklyWarningType;
|
|
97
|
+
/**
|
|
98
|
+
* Human-readable warning message
|
|
99
|
+
*/
|
|
100
|
+
message: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Checkly-specific extensions added to JSONReportTestResult
|
|
104
|
+
*/
|
|
105
|
+
interface ChecklyTestResultExtensions {
|
|
106
|
+
/**
|
|
107
|
+
* Warnings about the test result (e.g., missing traces)
|
|
108
|
+
*/
|
|
109
|
+
warnings?: ChecklyWarning[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Extended JSONReportTestResult with Checkly-specific data
|
|
113
|
+
*/
|
|
114
|
+
type JSONReportTestResult = JSONReportTestResult$1 & {
|
|
115
|
+
_checkly?: ChecklyTestResultExtensions;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Extended JSONReportTest with Checkly-extended results
|
|
119
|
+
*/
|
|
120
|
+
type JSONReportTest = Omit<JSONReportTest$1, 'results'> & {
|
|
121
|
+
results: JSONReportTestResult[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Extended JSONReportSpec with Checkly-extended tests
|
|
125
|
+
*/
|
|
126
|
+
type JSONReportSpec = Omit<JSONReportSpec$1, 'tests'> & {
|
|
127
|
+
tests: JSONReportTest[];
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Extended JSONReportSuite with Checkly-extended specs and nested suites
|
|
131
|
+
*/
|
|
132
|
+
type JSONReportSuite = Omit<JSONReportSuite$1, 'suites' | 'specs'> & {
|
|
133
|
+
suites?: JSONReportSuite[];
|
|
134
|
+
specs: JSONReportSpec[];
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Extended JSONReport with Checkly-extended suites
|
|
138
|
+
*/
|
|
139
|
+
type JSONReport = Omit<JSONReport$1, 'suites'> & {
|
|
140
|
+
suites: JSONReportSuite[];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Checkly Playwright Reporter
|
|
145
|
+
*
|
|
146
|
+
* Creates a ZIP archive containing the JSON report and all test assets.
|
|
147
|
+
* Designed to work alongside Playwright's built-in JSONReporter.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // playwright.config.ts
|
|
151
|
+
* export default defineConfig({
|
|
152
|
+
* reporter: [
|
|
153
|
+
* ['json', { outputFile: 'test-results/playwright-test-report.json' }],
|
|
154
|
+
* ['@checkly/playwright-reporter', {
|
|
155
|
+
* apiKey: process.env.CHECKLY_API_KEY,
|
|
156
|
+
* accountId: process.env.CHECKLY_ACCOUNT_ID,
|
|
157
|
+
* }]
|
|
158
|
+
* ]
|
|
159
|
+
* });
|
|
160
|
+
*/
|
|
161
|
+
declare class ChecklyReporter implements Reporter {
|
|
162
|
+
private options;
|
|
163
|
+
private assetCollector;
|
|
164
|
+
private zipper;
|
|
165
|
+
private testResults?;
|
|
166
|
+
private testSession?;
|
|
167
|
+
private startTime?;
|
|
168
|
+
private testCounts;
|
|
169
|
+
private stepsMap;
|
|
170
|
+
private warningsMap;
|
|
171
|
+
constructor(options?: ChecklyReporterOptions);
|
|
172
|
+
/**
|
|
173
|
+
* Resolves the session name from options
|
|
174
|
+
* Supports string, callback function, or falls back to default
|
|
175
|
+
*/
|
|
176
|
+
private resolveSessionName;
|
|
177
|
+
/**
|
|
178
|
+
* Checks if test result has a trace attachment and adds context-aware warning if missing
|
|
179
|
+
* The warning type depends on the trace configuration and test result state
|
|
180
|
+
*/
|
|
181
|
+
private checkTraceAttachment;
|
|
182
|
+
/**
|
|
183
|
+
* Called once before running tests
|
|
184
|
+
* Creates test session in Checkly if credentials provided
|
|
185
|
+
*/
|
|
186
|
+
onBegin(config: FullConfig, suite: Suite): void;
|
|
187
|
+
/**
|
|
188
|
+
* Called for each test when it completes
|
|
189
|
+
* Captures steps and warnings, tracks test results for final status calculation
|
|
190
|
+
*/
|
|
191
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
192
|
+
/**
|
|
193
|
+
* Called after all tests have completed
|
|
194
|
+
* This is where we create the ZIP archive and upload results
|
|
195
|
+
*/
|
|
196
|
+
onEnd(): Promise<void>;
|
|
197
|
+
private printSummary;
|
|
198
|
+
/**
|
|
199
|
+
* Injects captured steps and warnings into the JSON report
|
|
200
|
+
* Traverses the report structure and matches by test ID + retry
|
|
201
|
+
*/
|
|
202
|
+
private injectDataIntoReport;
|
|
203
|
+
/**
|
|
204
|
+
* Uploads test results to Checkly API
|
|
205
|
+
*/
|
|
206
|
+
private uploadResults;
|
|
207
|
+
/**
|
|
208
|
+
* Called when a global error occurs
|
|
209
|
+
*/
|
|
210
|
+
onError(error: TestError): void;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { ChecklyReporter, type ChecklyReporterOptions, type ChecklyTestResultExtensions, type ChecklyWarning, type ChecklyWarningType, type JSONReport, type JSONReportSpec, type JSONReportSuite, type JSONReportTest, type JSONReportTestResult, ChecklyReporter as default };
|