@testream/playwright-reporter 0.4.0 → 0.4.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/README.md +11 -274
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,292 +1,29 @@
|
|
|
1
1
|
# @testream/playwright-reporter
|
|
2
2
|
|
|
3
|
-
Playwright
|
|
3
|
+
Bridges Playwright test runs from your codebase into Jira with Testream. Once configured, it uploads results automatically.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- **Docs:** https://testream.github.io/docs/reporters/playwright
|
|
6
|
+
- **Docs repository:** https://github.com/testream/docs
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- 📊 **Automatic Upload** - Uploads test results and artifacts to Testream
|
|
9
|
-
- 📎 **Artifact Support** - Automatically uploads screenshots, videos, and traces
|
|
10
|
-
- 🔄 **CI/CD Ready** - Auto-detects git context from GitHub Actions, GitLab CI, CircleCI, Jenkins
|
|
11
|
-
- ⚙️ **Configurable** - Full control over upload behavior and metadata
|
|
12
|
-
- 🛡️ **Error Handling** - Graceful failure modes with optional strict mode
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
8
|
+
## Quick Start
|
|
15
9
|
|
|
16
10
|
```bash
|
|
17
11
|
npm install --save-dev @testream/playwright-reporter
|
|
18
12
|
```
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Add the reporter to your `playwright.config.ts`:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { defineConfig } from '@playwright/test';
|
|
26
|
-
|
|
27
|
-
export default defineConfig({
|
|
28
|
-
reporter: [
|
|
29
|
-
['list'], // Keep the default list reporter
|
|
30
|
-
[
|
|
31
|
-
'@testream/playwright-reporter',
|
|
32
|
-
{
|
|
33
|
-
// Required: API configuration
|
|
34
|
-
apiKey: process.env.TESTREAM_API_KEY,
|
|
35
|
-
projectKey: 'PROJECT-1',
|
|
36
|
-
|
|
37
|
-
// Optional: Git context (auto-detected in CI environments)
|
|
38
|
-
branch: process.env.BRANCH_NAME,
|
|
39
|
-
commitSha: process.env.COMMIT_SHA,
|
|
40
|
-
|
|
41
|
-
// Optional: Upload behavior
|
|
42
|
-
uploadEnabled: true,
|
|
43
|
-
failOnUploadError: false,
|
|
44
|
-
|
|
45
|
-
// Optional: CTRF report options
|
|
46
|
-
outputFile: 'ctrf-report.json',
|
|
47
|
-
outputDir: 'ctrf',
|
|
48
|
-
screenshot: true,
|
|
49
|
-
annotations: false,
|
|
50
|
-
testType: 'e2e',
|
|
51
|
-
|
|
52
|
-
// Optional: Environment metadata
|
|
53
|
-
appName: 'My App',
|
|
54
|
-
appVersion: '1.0.0',
|
|
55
|
-
buildName: 'Build #123',
|
|
56
|
-
buildNumber: '123',
|
|
57
|
-
buildUrl: 'https://ci.example.com/build/123',
|
|
58
|
-
testEnvironment: 'staging',
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
],
|
|
62
|
-
// ... other config
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Configuration Options
|
|
67
|
-
|
|
68
|
-
### Required Options
|
|
69
|
-
|
|
70
|
-
| Option | Type | Description |
|
|
71
|
-
|--------|------|-------------|
|
|
72
|
-
| `apiKey` | `string` | API key for authentication (store in environment variables) |
|
|
73
|
-
| `projectKey` | `string` | Project key to associate test results with |
|
|
74
|
-
|
|
75
|
-
### Optional Options
|
|
76
|
-
|
|
77
|
-
| Option | Type | Default | Description |
|
|
78
|
-
|--------|------|---------|-------------|
|
|
79
|
-
| `uploadEnabled` | `boolean` | `true` | Enable/disable automatic upload to backend |
|
|
80
|
-
| `failOnUploadError` | `boolean` | `false` | Fail the test run if upload fails |
|
|
81
|
-
| `branch` | `string` | Auto-detected | Git branch name |
|
|
82
|
-
| `commitSha` | `string` | Auto-detected | Git commit SHA |
|
|
83
|
-
| `outputFile` | `string` | `'ctrf-report.json'` | Local CTRF report filename |
|
|
84
|
-
| `outputDir` | `string` | `'ctrf'` | Local CTRF report directory |
|
|
85
|
-
| `screenshot` | `boolean` | `true` | Include screenshots in the report |
|
|
86
|
-
| `annotations` | `boolean` | `false` | Include Playwright annotations |
|
|
87
|
-
| `testType` | `string` | `'e2e'` | Test type (e.g., 'api', 'e2e', 'unit') |
|
|
88
|
-
| `appName` | `string` | - | Application name under test |
|
|
89
|
-
| `appVersion` | `string` | - | Application version under test |
|
|
90
|
-
| `buildName` | `string` | - | Build name |
|
|
91
|
-
| `buildNumber` | `string` | - | Build number |
|
|
92
|
-
| `buildUrl` | `string` | - | Build URL |
|
|
93
|
-
| `testEnvironment` | `string` | - | Test environment (e.g., 'staging', 'production') |
|
|
94
|
-
|
|
95
|
-
## Usage
|
|
96
|
-
|
|
97
|
-
### Basic Usage
|
|
98
|
-
|
|
99
|
-
Once configured, the reporter automatically:
|
|
100
|
-
1. Generates a CTRF report during test execution
|
|
101
|
-
2. Uploads the report to your backend after tests complete
|
|
102
|
-
3. Uploads any test artifacts (screenshots, videos, traces)
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
npx playwright test
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Capturing Screenshots
|
|
109
|
-
|
|
110
|
-
To include screenshots in your reports, attach them in your tests:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
import { test, expect } from '@playwright/test';
|
|
114
|
-
|
|
115
|
-
test('example test', async ({ page }, testInfo) => {
|
|
116
|
-
await page.goto('https://playwright.dev');
|
|
117
|
-
|
|
118
|
-
// Capture screenshot
|
|
119
|
-
const screenshot = await page.screenshot({
|
|
120
|
-
quality: 50,
|
|
121
|
-
type: 'jpeg'
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await testInfo.attach('screenshot', {
|
|
125
|
-
body: screenshot,
|
|
126
|
-
contentType: 'image/jpeg',
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Disable Upload for Local Development
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
14
|
+
```ts
|
|
134
15
|
// playwright.config.ts
|
|
135
|
-
export default defineConfig({
|
|
136
|
-
reporter: [
|
|
137
|
-
[
|
|
138
|
-
'@testream/playwright-reporter',
|
|
139
|
-
{
|
|
140
|
-
apiKey: process.env.TESTREAM_API_KEY,
|
|
141
|
-
projectKey: 'PROJECT-1',
|
|
142
|
-
uploadEnabled: process.env.CI === 'true', // Only upload in CI
|
|
143
|
-
},
|
|
144
|
-
],
|
|
145
|
-
],
|
|
146
|
-
});
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Environment Variables
|
|
150
|
-
|
|
151
|
-
It's recommended to store sensitive configuration in environment variables:
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
# .env
|
|
155
|
-
TESTREAM_API_KEY=your-api-key-here
|
|
156
|
-
TESTREAM_PROJECT_KEY=PROJECT-1
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Then load them in your config:
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
16
|
import { defineConfig } from '@playwright/test';
|
|
163
|
-
import * as dotenv from 'dotenv';
|
|
164
|
-
|
|
165
|
-
dotenv.config();
|
|
166
17
|
|
|
167
18
|
export default defineConfig({
|
|
168
19
|
reporter: [
|
|
169
|
-
[
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
],
|
|
20
|
+
['@testream/playwright-reporter', {
|
|
21
|
+
apiKey: process.env.TESTREAM_API_KEY,
|
|
22
|
+
projectKey: 'PROJ',
|
|
23
|
+
uploadEnabled: true,
|
|
24
|
+
}],
|
|
176
25
|
],
|
|
177
26
|
});
|
|
178
27
|
```
|
|
179
28
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
### GitHub Actions
|
|
183
|
-
|
|
184
|
-
The reporter automatically detects GitHub Actions environment variables:
|
|
185
|
-
|
|
186
|
-
```yaml
|
|
187
|
-
name: Playwright Tests
|
|
188
|
-
on: [push, pull_request]
|
|
189
|
-
|
|
190
|
-
jobs:
|
|
191
|
-
test:
|
|
192
|
-
runs-on: ubuntu-latest
|
|
193
|
-
steps:
|
|
194
|
-
- uses: actions/checkout@v4
|
|
195
|
-
|
|
196
|
-
- name: Setup Node.js
|
|
197
|
-
uses: actions/setup-node@v4
|
|
198
|
-
with:
|
|
199
|
-
node-version: '20'
|
|
200
|
-
|
|
201
|
-
- name: Install dependencies
|
|
202
|
-
run: npm ci
|
|
203
|
-
|
|
204
|
-
- name: Install Playwright Browsers
|
|
205
|
-
run: npx playwright install --with-deps
|
|
206
|
-
|
|
207
|
-
- run: npx playwright test
|
|
208
|
-
env:
|
|
209
|
-
TESTREAM_API_KEY: ${{ secrets.TESTREAM_API_KEY }}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### GitLab CI
|
|
213
|
-
|
|
214
|
-
```yaml
|
|
215
|
-
test:
|
|
216
|
-
image: mcr.microsoft.com/playwright:latest
|
|
217
|
-
script:
|
|
218
|
-
- npm ci
|
|
219
|
-
- npx playwright test
|
|
220
|
-
variables:
|
|
221
|
-
TESTREAM_API_KEY: $TESTREAM_API_KEY
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### CircleCI
|
|
225
|
-
|
|
226
|
-
```yaml
|
|
227
|
-
version: 2.1
|
|
228
|
-
jobs:
|
|
229
|
-
test:
|
|
230
|
-
docker:
|
|
231
|
-
- image: mcr.microsoft.com/playwright:latest
|
|
232
|
-
steps:
|
|
233
|
-
- checkout
|
|
234
|
-
- run: npm ci
|
|
235
|
-
- run: npx playwright test
|
|
236
|
-
environment:
|
|
237
|
-
TESTREAM_API_KEY: $TESTREAM_API_KEY
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## Troubleshooting
|
|
241
|
-
|
|
242
|
-
### Upload Failures
|
|
243
|
-
|
|
244
|
-
If uploads fail, the reporter logs detailed error messages but doesn't fail your tests by default:
|
|
245
|
-
|
|
246
|
-
```
|
|
247
|
-
❌ Failed to upload report: API ingest failed: HTTP 401: Unauthorized
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
To make upload failures fail the test run:
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
{
|
|
254
|
-
failOnUploadError: true
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### Missing Artifacts
|
|
259
|
-
|
|
260
|
-
Ensure artifacts are properly attached in tests and that file paths are accessible when the reporter runs.
|
|
261
|
-
|
|
262
|
-
### Git Context Not Detected
|
|
263
|
-
|
|
264
|
-
Manually specify branch and commit in configuration:
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
{
|
|
268
|
-
branch: process.env.GIT_BRANCH || 'main',
|
|
269
|
-
commitSha: process.env.GIT_COMMIT || 'unknown',
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## How It Works
|
|
274
|
-
|
|
275
|
-
1. **Test Execution**: Playwright runs your tests
|
|
276
|
-
2. **Report Generation**: A test report is generated in standard format
|
|
277
|
-
3. **Report Upload**: The report is uploaded to Testream
|
|
278
|
-
4. **Artifact Upload**: Test artifacts (screenshots, videos, etc.) are uploaded
|
|
279
|
-
5. **Results Display**: View your results in the Testream dashboard
|
|
280
|
-
|
|
281
|
-
## Related Packages
|
|
282
|
-
|
|
283
|
-
- [playwright-ctrf-json-reporter](https://www.npmjs.com/package/playwright-ctrf-json-reporter) - Underlying CTRF reporter
|
|
284
|
-
- [@testream/upload-action](https://www.npmjs.com/package/@testream/upload-action) - CLI and GitHub Action for uploading CTRF reports
|
|
285
|
-
|
|
286
|
-
## License
|
|
287
|
-
|
|
288
|
-
Proprietary - See LICENSE file
|
|
289
|
-
|
|
290
|
-
## Support
|
|
291
|
-
|
|
292
|
-
For issues and questions, visit the [Testream Support Portal](https://testream.example.com/support).
|
|
29
|
+
Need more configuration options? See the full guide at https://testream.github.io/docs/reporters/playwright.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testream/playwright-reporter",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Playwright CTRF reporter with automatic upload to Testream",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/
|
|
17
|
+
"url": "git+https://github.com/testream/docs.git"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"playwright",
|