@checkly/playwright-reporter 0.1.10 → 1.0.0

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.
Files changed (4) hide show
  1. package/README.md +266 -0
  2. package/dist/index.d.ts +343 -267
  3. package/dist/index.js +1597 -789
  4. package/package.json +16 -14
package/README.md ADDED
@@ -0,0 +1,266 @@
1
+ # @checkly/playwright-reporter
2
+
3
+ > **Technical Preview** - This reporter is currently in technical preview. Features and APIs may change.
4
+
5
+ Official Playwright reporter for Checkly. Automatically upload test results, screenshots, videos, and traces to gain visibility into your end-to-end tests.
6
+
7
+ **Fully compatible with Playwright's native JSON reporter** - use it as a drop-in replacement that adds Checkly integration.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install --save-dev @checkly/playwright-reporter
13
+ ```
14
+
15
+ **Requirements:**
16
+ - Node.js >= 18.0.0
17
+ - Playwright >= 1.40.0
18
+ - A [Checkly account](https://app.checklyhq.com)
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Get Your Credentials
23
+
24
+ 1. Go to **Account Settings > General** to find your Account ID
25
+ 2. Go to **User Settings > API Keys** to create an API key
26
+
27
+ ### 2. Configure Playwright
28
+
29
+ Add the reporter to your `playwright.config.ts`:
30
+
31
+ ```typescript
32
+ import { defineConfig } from '@playwright/test';
33
+ import { createChecklyReporter } from '@checkly/playwright-reporter';
34
+
35
+ export default defineConfig({
36
+ reporter: [
37
+ ['list'],
38
+ createChecklyReporter(),
39
+ ],
40
+ });
41
+ ```
42
+
43
+ > **Tip:** Using `createChecklyReporter()` provides full intellisense for configuration options. Alternatively, use the array syntax: `['@checkly/playwright-reporter', { ... }]`
44
+
45
+ ### 3. Set Environment Variables
46
+
47
+ ```bash
48
+ export CHECKLY_API_KEY=your_api_key
49
+ export CHECKLY_ACCOUNT_ID=your_account_id
50
+ ```
51
+
52
+ Or pass them inline:
53
+
54
+ ```bash
55
+ CHECKLY_API_KEY=... CHECKLY_ACCOUNT_ID=... npx playwright test
56
+ ```
57
+
58
+ ### 4. Run Tests
59
+
60
+ ```bash
61
+ npx playwright test
62
+ ```
63
+
64
+ You'll see a session URL in the output:
65
+
66
+ ```
67
+ View test results: https://app.checklyhq.com/test-sessions/abc123
68
+
69
+ [...test execution...]
70
+
71
+ ✓ Check the results: https://app.checklyhq.com/test-sessions/abc123
72
+ ```
73
+
74
+ ## Configuration Options
75
+
76
+ ```typescript
77
+ import { createChecklyReporter } from '@checkly/playwright-reporter';
78
+
79
+ createChecklyReporter({
80
+ outputDir: 'test-results',
81
+ sessionName: 'My Test Suite',
82
+ dryRun: false,
83
+ verbose: false,
84
+ })
85
+ ```
86
+
87
+ | Option | Type | Default | Description |
88
+ |--------|------|---------|-------------|
89
+ | `outputDir` | `string` | Playwright's `outputDir` | Directory for assets, JSON, and ZIP |
90
+ | `sessionName` | `string \| function` | Auto-generated | Custom session name |
91
+ | `dryRun` | `boolean` | `false` | Create ZIP without uploading |
92
+ | `verbose` | `boolean` | `false` | Enable debug logging |
93
+
94
+ **Output files** (written to `outputDir`):
95
+ - `checkly-report.json` - JSON test report
96
+ - `checkly-report.zip` - ZIP archive with report and assets
97
+
98
+ **Deprecated options** (will be removed in next major version):
99
+ | Option | Migration |
100
+ |--------|-----------|
101
+ | `outputFile` | JSON now at `{outputDir}/checkly-report.json` |
102
+ | `testResultsDir` | Use `outputDir` |
103
+ | `outputPath` | ZIP now at `{outputDir}/checkly-report.zip` |
104
+
105
+ ## Environment Variables
106
+
107
+ | Variable | Description |
108
+ |----------|-------------|
109
+ | `CHECKLY_API_KEY` | Your Checkly API key |
110
+ | `CHECKLY_ACCOUNT_ID` | Your Checkly account ID |
111
+ | `CHECKLY_REPORTER_VERBOSE` | Set to `true` for detailed debug output |
112
+
113
+ ## What Gets Uploaded
114
+
115
+ - Test results and status (passed/failed/flaky)
116
+ - Execution duration and timing
117
+ - Screenshots (on failure or explicit capture)
118
+ - Video recordings
119
+ - Playwright traces
120
+ - Console logs and network requests (extracted from traces)
121
+
122
+ ## Flaky Test Detection
123
+
124
+ The reporter automatically detects flaky tests:
125
+
126
+ - **Flaky test**: A test that failed initially but passed after retry
127
+ - **Degraded status**: Set when there are flaky tests but no complete failures
128
+ - **Overall status**: `passed` if all tests eventually pass, `failed` otherwise
129
+
130
+ ## Running Locally (No Upload)
131
+
132
+ For local development without uploading to Checkly:
133
+
134
+ ```bash
135
+ # Simply don't set CHECKLY_API_KEY or CHECKLY_ACCOUNT_ID
136
+ npx playwright test
137
+ ```
138
+
139
+ What happens:
140
+ - Reporter creates `checkly-report.zip` locally
141
+ - Upload is automatically skipped
142
+ - Tests run normally
143
+ - You can inspect the ZIP file for debugging
144
+
145
+ ## Dry Run Mode
146
+
147
+ Create local JSON and ZIP files without uploading:
148
+
149
+ ```typescript
150
+ createChecklyReporter({
151
+ dryRun: true,
152
+ })
153
+ ```
154
+
155
+ Conditional dry run (skip uploads when no credentials):
156
+
157
+ ```typescript
158
+ createChecklyReporter({
159
+ dryRun: !process.env.CHECKLY_API_KEY,
160
+ })
161
+ ```
162
+
163
+ ## CI/CD Integration
164
+
165
+ ### GitHub Actions
166
+
167
+ ```yaml
168
+ name: Playwright Tests
169
+ on: [push, pull_request]
170
+
171
+ jobs:
172
+ test:
173
+ runs-on: ubuntu-latest
174
+ steps:
175
+ - uses: actions/checkout@v4
176
+
177
+ - uses: actions/setup-node@v4
178
+ with:
179
+ node-version: 20
180
+
181
+ - name: Install dependencies
182
+ run: npm ci
183
+
184
+ - name: Install Playwright browsers
185
+ run: npx playwright install --with-deps
186
+
187
+ - name: Run Playwright tests
188
+ env:
189
+ CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }}
190
+ CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }}
191
+ run: npx playwright test
192
+ ```
193
+
194
+ ### GitLab CI
195
+
196
+ ```yaml
197
+ test:
198
+ image: mcr.microsoft.com/playwright:v1.57.0-jammy
199
+ stage: test
200
+ script:
201
+ - npm ci
202
+ - npx playwright test
203
+ variables:
204
+ CHECKLY_API_KEY: $CHECKLY_API_KEY
205
+ CHECKLY_ACCOUNT_ID: $CHECKLY_ACCOUNT_ID
206
+ ```
207
+
208
+ **Setting up variables:**
209
+ 1. Go to your GitLab project
210
+ 2. Navigate to Settings > CI/CD > Variables
211
+ 3. Add `CHECKLY_API_KEY` (check "Mask variable")
212
+ 4. Add `CHECKLY_ACCOUNT_ID` (check "Mask variable")
213
+
214
+ ## Multiple Reporters
215
+
216
+ Combine with other Playwright reporters:
217
+
218
+ ```typescript
219
+ import { createChecklyReporter } from '@checkly/playwright-reporter';
220
+
221
+ export default defineConfig({
222
+ reporter: [
223
+ createChecklyReporter(),
224
+ ['html', { outputFolder: 'playwright-report' }],
225
+ ['list'],
226
+ ['junit', { outputFile: 'test-results/junit.xml' }],
227
+ ],
228
+ });
229
+ ```
230
+
231
+ ## Understanding Test Sessions
232
+
233
+ The reporter creates **suite-level test sessions**, not individual test file results.
234
+
235
+ When you run `npx playwright test`:
236
+
237
+ 1. **One test session** is created, named after your directory
238
+ 2. **One test result** for the entire run
239
+ 3. **All assets uploaded together** in a single ZIP file
240
+
241
+ Benefits:
242
+ - Consolidated view of your entire test suite
243
+ - Efficient storage
244
+ - Track overall pass/fail rates over time
245
+
246
+ ## Security
247
+
248
+ Always use environment variables for credentials. Never commit API keys to version control.
249
+
250
+ ```typescript
251
+ // DON'T DO THIS
252
+ createChecklyReporter({
253
+ apiKey: 'chk_api_...', // Hardcoded credentials!
254
+ })
255
+
256
+ // DO THIS
257
+ createChecklyReporter() // Reads from environment
258
+ ```
259
+
260
+ ## Documentation
261
+
262
+ For detailed documentation, visit [checklyhq.com/docs/detect/testing/playwright-reporter](https://www.checklyhq.com/docs/detect/testing/playwright-reporter/).
263
+
264
+ ## License
265
+
266
+ Apache 2.0