@m00nsolutions/playwright-reporter 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.
- package/LICENSE +21 -0
- package/README.md +248 -0
- package/index.mjs +2386 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 M00n Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# @m00nsolutions/playwright-reporter
|
|
2
|
+
|
|
3
|
+
Official Playwright test reporter for [M00n Report](https://m00nreport.com) - a real-time test reporting dashboard.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Real-time streaming** - Watch test steps execute live in the dashboard
|
|
8
|
+
- 📎 **Attachment support** - Screenshots, videos, traces, and custom files
|
|
9
|
+
- 🔄 **Retry tracking** - Automatic tracking of test retries with attempt history
|
|
10
|
+
- 🏷️ **Tags & attributes** - Organize runs with custom metadata
|
|
11
|
+
- 📊 **Performance metrics** - Detailed timing and bottleneck analysis
|
|
12
|
+
- 🔒 **Secure** - API key authentication per project
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @m00nsolutions/playwright-reporter --save-dev
|
|
18
|
+
# or
|
|
19
|
+
yarn add @m00nsolutions/playwright-reporter --dev
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @m00nsolutions/playwright-reporter --save-dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### 1. Get your API key
|
|
27
|
+
|
|
28
|
+
1. Log in to [M00n Report](https://m00nreport.com)
|
|
29
|
+
2. Navigate to your project settings
|
|
30
|
+
3. Generate or copy your project API key
|
|
31
|
+
|
|
32
|
+
### 2. Configure Playwright
|
|
33
|
+
|
|
34
|
+
Add the reporter to your `playwright.config.ts`:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { defineConfig } from '@playwright/test';
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
reporter: [
|
|
41
|
+
['list'], // Keep default console output
|
|
42
|
+
['@m00nsolutions/playwright-reporter', {
|
|
43
|
+
serverUrl: 'https://ingest.m00nreport.com', // Or your self-hosted URL
|
|
44
|
+
apiKey: process.env.M00N_API_KEY, // Your project API key
|
|
45
|
+
launch: 'Regression Suite', // Optional: run title
|
|
46
|
+
tags: ['smoke', 'regression'], // Optional: tags
|
|
47
|
+
attributes: { // Optional: custom metadata
|
|
48
|
+
environment: 'staging',
|
|
49
|
+
branch: process.env.GIT_BRANCH,
|
|
50
|
+
},
|
|
51
|
+
}],
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. Run your tests
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx playwright test
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
That's it! Your test results will appear in the M00n Report dashboard in real-time.
|
|
63
|
+
|
|
64
|
+
## Configuration Options
|
|
65
|
+
|
|
66
|
+
| Option | Type | Default | Description |
|
|
67
|
+
|--------|------|---------|-------------|
|
|
68
|
+
| `serverUrl` | `string` | **required** | M00n Report ingest service URL |
|
|
69
|
+
| `apiKey` | `string` | **required** | Project API key (identifies org and project) |
|
|
70
|
+
| `launch` | `string` | `'Run {date}'` | Title for this test run |
|
|
71
|
+
| `tags` | `string[]` | `[]` | Tags to categorize the run |
|
|
72
|
+
| `attributes` | `object` | `{}` | Custom key-value metadata |
|
|
73
|
+
| `realtime` | `boolean` | `true` | Enable real-time step streaming |
|
|
74
|
+
| `binaryAttachments` | `boolean` | `true` | Use efficient binary uploads |
|
|
75
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
76
|
+
| `verbose` | `boolean` | `false` | Enable performance timing logs |
|
|
77
|
+
| `logFile` | `string` | `null` | Path to save performance metrics |
|
|
78
|
+
|
|
79
|
+
## Environment Variables
|
|
80
|
+
|
|
81
|
+
You can also configure the reporter via environment variables:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
M00N_SERVER_URL=https://ingest.m00nreport.com
|
|
85
|
+
M00N_API_KEY=m00n_xxxxxxxxxxxxx
|
|
86
|
+
M00N_LAUNCH="Nightly Build"
|
|
87
|
+
M00N_TAGS=smoke,regression
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Usage Examples
|
|
91
|
+
|
|
92
|
+
### Basic Configuration
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
reporter: [
|
|
96
|
+
['@m00nsolutions/playwright-reporter', {
|
|
97
|
+
serverUrl: 'https://ingest.m00nreport.com',
|
|
98
|
+
apiKey: process.env.M00N_API_KEY,
|
|
99
|
+
}],
|
|
100
|
+
],
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### CI/CD Configuration
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
reporter: [
|
|
107
|
+
['@m00nsolutions/playwright-reporter', {
|
|
108
|
+
serverUrl: 'https://ingest.m00nreport.com',
|
|
109
|
+
apiKey: process.env.M00N_API_KEY,
|
|
110
|
+
launch: `Build #${process.env.BUILD_NUMBER}`,
|
|
111
|
+
tags: [process.env.CI_ENVIRONMENT, 'automated'],
|
|
112
|
+
attributes: {
|
|
113
|
+
ciJobUrl: process.env.CI_JOB_URL,
|
|
114
|
+
gitBranch: process.env.GIT_BRANCH,
|
|
115
|
+
gitCommit: process.env.GIT_COMMIT,
|
|
116
|
+
triggeredBy: process.env.GITLAB_USER_LOGIN,
|
|
117
|
+
},
|
|
118
|
+
}],
|
|
119
|
+
],
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Link Test Cases
|
|
123
|
+
|
|
124
|
+
Use annotations to link tests to test case IDs in your test management system:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { test } from '@playwright/test';
|
|
128
|
+
|
|
129
|
+
test('user can login @caseId=TC-123', async ({ page }) => {
|
|
130
|
+
// Your test code
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Or use the annotation API
|
|
134
|
+
test('user can logout', async ({ page }) => {
|
|
135
|
+
test.info().annotations.push({ type: 'caseId', description: 'TC-456' });
|
|
136
|
+
// Your test code
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Custom Tags per Test
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
test('critical checkout flow', async ({ page }) => {
|
|
144
|
+
test.info().annotations.push({ type: 'tags', description: ['critical', 'checkout'] });
|
|
145
|
+
// Your test code
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Real-time Step Streaming
|
|
150
|
+
|
|
151
|
+
When `realtime: true` (default), the reporter streams test steps to the dashboard as they execute. This allows you to:
|
|
152
|
+
|
|
153
|
+
- Watch tests execute in real-time
|
|
154
|
+
- See which step is currently running
|
|
155
|
+
- Identify failures immediately without waiting for test completion
|
|
156
|
+
|
|
157
|
+
## Attachment Handling
|
|
158
|
+
|
|
159
|
+
The reporter automatically uploads all Playwright attachments:
|
|
160
|
+
|
|
161
|
+
- **Screenshots** - Captured on failure or explicitly
|
|
162
|
+
- **Videos** - When video recording is enabled
|
|
163
|
+
- **Traces** - Playwright trace files for debugging
|
|
164
|
+
- **Custom files** - Any files you attach in tests
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
test('with attachments', async ({ page }) => {
|
|
168
|
+
// Screenshot on failure is automatic
|
|
169
|
+
|
|
170
|
+
// Explicit screenshot
|
|
171
|
+
await page.screenshot({ path: 'screenshot.png' });
|
|
172
|
+
|
|
173
|
+
// Custom attachment
|
|
174
|
+
await test.info().attach('api-response', {
|
|
175
|
+
body: JSON.stringify(response),
|
|
176
|
+
contentType: 'application/json',
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Performance Optimization
|
|
182
|
+
|
|
183
|
+
For high-parallelism runs (30+ workers), the reporter includes:
|
|
184
|
+
|
|
185
|
+
- **Upload concurrency limiting** - Prevents server overload
|
|
186
|
+
- **Request batching** - Reduces HTTP overhead
|
|
187
|
+
- **Large file streaming** - Efficient handling of big traces
|
|
188
|
+
- **Backpressure control** - Graceful degradation under load
|
|
189
|
+
|
|
190
|
+
Enable verbose logging to analyze performance:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
reporter: [
|
|
194
|
+
['@m00nsolutions/playwright-reporter', {
|
|
195
|
+
serverUrl: 'https://ingest.m00nreport.com',
|
|
196
|
+
apiKey: process.env.M00N_API_KEY,
|
|
197
|
+
verbose: true,
|
|
198
|
+
logFile: './m00n-performance.log',
|
|
199
|
+
}],
|
|
200
|
+
],
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Self-Hosted
|
|
204
|
+
|
|
205
|
+
For self-hosted M00n Report installations, point to your ingest service:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
reporter: [
|
|
209
|
+
['@m00nsolutions/playwright-reporter', {
|
|
210
|
+
serverUrl: 'https://your-domain.com:4001', // Your ingest service
|
|
211
|
+
apiKey: process.env.M00N_API_KEY,
|
|
212
|
+
}],
|
|
213
|
+
],
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Troubleshooting
|
|
217
|
+
|
|
218
|
+
### Reporter is disabled
|
|
219
|
+
|
|
220
|
+
Check the console output for messages like:
|
|
221
|
+
- `"serverUrl" is required` - Ensure serverUrl is configured
|
|
222
|
+
- `"apiKey" is required` - Ensure apiKey is configured
|
|
223
|
+
- `Server unavailable` - Check network connectivity to the server
|
|
224
|
+
|
|
225
|
+
### Missing test results
|
|
226
|
+
|
|
227
|
+
1. Ensure the ingest service is running and accessible
|
|
228
|
+
2. Check your API key is valid for the project
|
|
229
|
+
3. Enable debug mode to see detailed logging:
|
|
230
|
+
```typescript
|
|
231
|
+
debug: true
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Large trace files
|
|
235
|
+
|
|
236
|
+
For very large trace files (>100MB), increase timeouts or consider:
|
|
237
|
+
- Using `retain-on-failure` instead of `on` for traces
|
|
238
|
+
- Reducing trace content with `screenshots: 'off'`
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
243
|
+
|
|
244
|
+
## Support
|
|
245
|
+
|
|
246
|
+
- 📖 [Documentation](https://docs.m00nreport.com)
|
|
247
|
+
- 🐛 [Report Issues](https://github.com/m00nsolutions/m00nreport/issues)
|
|
248
|
+
- 💬 [Community Discord](https://discord.gg/m00nreport)
|