@sentinelqa/playwright-reporter 0.1.54 → 0.1.57

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 CHANGED
@@ -1,68 +1,38 @@
1
- # Playwright Reporter
1
+ # @sentinelqa/playwright-reporter
2
2
 
3
- After every failed Playwright run, Sentinel gives you:
4
-
5
- - a clear CLI diagnosis
6
- - a shareable debugging link
7
- - grouped failures by likely root cause
8
-
9
- Sample run: https://app.sentinelqa.com/share/1f343d91-be17-4c14-b1b9-2d4e8ef448d2
3
+ Deterministic Playwright failure triage: CLI diagnosis, root-cause grouping, and a shareable debugging report.
10
4
 
11
5
  [![npm](https://img.shields.io/npm/v/@sentinelqa/playwright-reporter)](https://www.npmjs.com/package/@sentinelqa/playwright-reporter)
12
6
  [![downloads](https://img.shields.io/npm/dm/@sentinelqa/playwright-reporter)](https://www.npmjs.com/package/@sentinelqa/playwright-reporter)
13
7
  [![license](https://img.shields.io/npm/l/@sentinelqa/playwright-reporter)](./LICENSE)
14
8
 
15
- From failed CI run to root cause in seconds.
16
-
17
- Works with no account and no API key.
18
-
19
- ![Sentinel Report Example](./docs/screenshot2.png)
20
- ![CLI Quick Diagnosis](./docs/CLI2.png)
21
-
22
- ## What It Does
23
-
24
- Sentinel explains Playwright failures locally, groups them into real root causes, and gives you a shareable link to inspect the run.
25
-
26
- The open-source reporter is focused on one job:
9
+ ## What You Get
27
10
 
28
- - tell you what broke
29
- - show why it failed
30
- - point to the likely root cause
31
- - tell you what to check next
11
+ SAMPLE REPORT: https://sentinelqa.com/share/run/permanent-demo-playwright-report
32
12
 
33
- ## Features
13
+ ![CLI Output](./docs/cli.png)
34
14
 
35
- - Free hosted debugging links by default
36
- - Deterministic CLI diagnosis after failed runs
37
- - Failure grouping by likely root cause
38
- - Shared run page with traces, screenshots, videos, and logs
39
- - Failure pages that explain what broke, why, where, and what to do next
40
- - Better timeout, actionability, assertion, navigation, and backend failure wording
41
- - Public share links that are easy to paste into Slack, PRs, and issues
42
- - Works with existing Playwright reporter setup
15
+ After a failed Playwright run, Sentinel prints:
43
16
 
44
- ## Why Teams Use It
45
-
46
- - You do not need to open raw logs first
47
- - Repeated failures collapse into a smaller number of real issues
48
- - The CLI explains the failure immediately in CI
49
- - Anyone on the team can open the same shared debugging link
50
- - The hosted report keeps the explanation, artifacts, and grouped failures in one place
17
+ - a deterministic CLI diagnosis (1–3 root causes)
18
+ - how many tests are affected per root cause
19
+ - what to inspect first (usually trace)
20
+ - a report link (hosted by default, local in offline mode)
51
21
 
52
22
  ## Requirements
53
23
 
54
24
  - Node.js 18+
55
- - `@playwright/test` 1.40+
56
-
57
- ## Quick Start
25
+ - `@playwright/test` 1.40+ (newer is recommended)
58
26
 
59
- Install:
27
+ ## Install
60
28
 
61
29
  ```bash
62
30
  npm install -D @sentinelqa/playwright-reporter
63
31
  ```
64
32
 
65
- Add Sentinel to your Playwright config:
33
+ ## Setup (Recommended)
34
+
35
+ Wrap your `playwright.config.ts`:
66
36
 
67
37
  ```ts
68
38
  import { defineConfig } from "@playwright/test";
@@ -72,11 +42,6 @@ export default withSentinel(
72
42
  defineConfig({
73
43
  reporter: [["line"]],
74
44
  outputDir: "test-results",
75
- use: {
76
- trace: "retain-on-failure",
77
- screenshot: "only-on-failure",
78
- video: "retain-on-failure",
79
- },
80
45
  }),
81
46
  {
82
47
  project: "my-app",
@@ -84,91 +49,118 @@ export default withSentinel(
84
49
  );
85
50
  ```
86
51
 
87
- Run your tests:
52
+ Run tests normally:
88
53
 
89
54
  ```bash
90
55
  npx playwright test
91
56
  ```
92
57
 
93
- If tests fail, Sentinel uploads the run and prints a shareable link in the terminal.
58
+ ## How It Works (High Level)
59
+
60
+ Sentinel is a Playwright reporter that:
61
+
62
+ 1. Ensures a Playwright JSON report exists (adds a JSON reporter if needed).
63
+ 2. Collects the artifacts Playwright already produces (`trace.zip`, screenshots, video, logs, report.json).
64
+ 3. Builds a **deterministic** failure summary:
65
+ - groups repeated failures into 1–3 canonical root causes
66
+ - extracts normalized evidence (where, blocker, target state, expected/received)
67
+ 4. Publishes a report:
68
+ - default: a hosted share link
69
+ - offline: a local HTML report folder (no upload)
70
+
71
+ This project is intentionally heuristic-driven (not “AI guesses”) for root-cause grouping.
94
72
 
95
- ## CLI Output
73
+ ## Modes
96
74
 
97
- On failed runs, Sentinel prints a compact diagnosis that answers:
75
+ Sentinel behavior is controlled by `SENTINEL_MODE`.
98
76
 
99
- 1. What failed?
100
- 2. What caused it?
101
- 3. Where is it?
102
- 4. What should I check next?
77
+ ### Hosted Mode (Default)
103
78
 
104
- Typical output:
79
+ Do nothing. Sentinel uploads and prints a share link when failures happen.
105
80
 
106
- ```text
107
- Sentinel diagnosis
108
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
81
+ Environment:
109
82
 
110
- RECURRING FAILURE (12 previous runs)
83
+ - `SENTINEL_MODE` unset (or `SENTINEL_MODE=hosted`)
111
84
 
112
- 4 failures (grouped)
113
- Collapsed into 2 real issues
85
+ ### Workspace Mode (Private History)
114
86
 
115
- Issue 1: Blocked click on getByRole('button', { name: 'Save' }) (3 tests)
116
- Cause: .modal-backdrop intercepted pointer events before the click completed
117
- Where: checkout.spec.ts:22; billing.spec.ts:41
118
- Failing step: Click on getByRole('button', { name: 'Save' }) selector
119
- Blocker: .modal-backdrop intercepting pointer events
120
- Likely fix: dismiss or wait for .modal-backdrop to disappear before clicking Save
121
- Impact: 3 tests failing with same root cause
87
+ If you have a workspace token:
122
88
 
123
- Issue 2: Assertion mismatch (getByTestId('metric-pass-rate')) (1 test)
124
- Cause: getByTestId('metric-pass-rate') showed "88%" instead of "100%"
125
- Where: app.spec.ts:68
126
- Failing step: Expect text on getByTestId('metric-pass-rate') selector
127
- Expected: 100%
128
- Received: 88%
129
- Likely fix: fix the UI state or data behind getByTestId('metric-pass-rate') so it shows "100%"
130
- Impact: 1 test failing with this root cause
89
+ ```bash
90
+ SENTINEL_TOKEN=your_project_ingest_token npx playwright test
131
91
  ```
132
92
 
133
- On passed runs, Sentinel stays quiet unless there is a strong risk signal worth surfacing.
93
+ Environment:
94
+
95
+ - `SENTINEL_MODE` unset (or `SENTINEL_MODE=hosted`)
96
+ - `SENTINEL_TOKEN=...`
97
+
98
+ ### Offline Mode (No Uploads)
99
+
100
+ To keep everything local:
101
+
102
+ ```bash
103
+ SENTINEL_MODE=offline npx playwright test
104
+ ```
134
105
 
135
- ## What The Shared Report Shows
106
+ Offline mode is strict:
136
107
 
137
- The hosted report is simple on purpose.
108
+ - uploads are skipped
109
+ - a local report is generated (default `./sentinel-report/index.html`)
110
+ - the CLI prints a local `file://` link (or a relative path)
138
111
 
139
- It focuses on:
112
+ If a hosted upload fails, Sentinel falls back to generating the local report automatically.
140
113
 
141
- - grouped failures
142
- - explanation of why each issue failed
143
- - affected tests
144
- - artifacts
145
- - recent history
114
+ ### Local Workspace Uploads (When Not In CI)
146
115
 
147
- Open the link to inspect:
116
+ If you set `SENTINEL_TOKEN` locally, Sentinel will _not_ upload by default (to avoid accidental data egress).
117
+ To allow a local upload to your workspace, set:
148
118
 
149
- - failures grouped by likely root cause
150
- - whether multiple failures appear related
151
- - the best available explanation for each issue
152
- - screenshots, traces, videos, and logs
153
- - direct links you can share with the rest of the team
119
+ ```bash
120
+ SENTINEL_UPLOAD_LOCAL=1 SENTINEL_TOKEN=your_project_ingest_token npx playwright test
121
+ ```
154
122
 
155
- ## Free Hosted Mode
123
+ This is useful for quickly generating a private run history entry from your laptop.
156
124
 
157
- If `SENTINEL_TOKEN` is not set, the reporter uploads the run to a free hosted Sentinel report and prints the public share URL.
125
+ ### Implicit Local Public Upload (No Token, Not In CI)
158
126
 
159
- This free flow includes:
127
+ If you are not in CI and you did not set `SENTINEL_TOKEN`, Sentinel can still upload in public mode by enabling:
160
128
 
161
- - CLI diagnosis
162
- - hosted run page
163
- - grouped failures
164
- - failure explanation
165
- - public share links
129
+ ```bash
130
+ SENTINEL_UPLOAD_LOCAL=1 npx playwright test
131
+ ```
166
132
 
167
- ## Optional Richer Capture
133
+ ### Share Links Are Optional (Open Source / Self-Hosted)
168
134
 
169
- `withSentinel()` works on its own and is the simplest setup.
135
+ - Hosted mode prints a share URL on failures.
136
+ - Offline mode skips uploads and produces only a local report.
170
137
 
171
- If you want richer failure evidence, you can also attach the failure capture fixture:
138
+ Pick the behavior explicitly with `SENTINEL_MODE` (and `SENTINEL_UPLOAD_LOCAL` for local uploads).
139
+
140
+ ## Serving Local Reports
141
+
142
+ Local reports are static HTML + copied artifacts. You can open `index.html` directly, or run a tiny local server:
143
+
144
+ ```bash
145
+ cd sentinel-report
146
+ npx --yes serve -p 4173 .
147
+ ```
148
+
149
+ Then open `http://localhost:4173`.
150
+
151
+ ## Secrets Masking
152
+
153
+ Sentinel masks common secret patterns before data is shared. This includes:
154
+
155
+ - environment-variable looking strings
156
+ - common credential/token patterns
157
+ - internal URLs/hosts (where possible)
158
+
159
+ If you find something that should be masked but isn’t, file an issue with a minimal reproducible example (redact the secret).
160
+
161
+ ## Optional: Richer Failure Evidence
162
+
163
+ `withSentinel()` is enough for most setups. If you want richer UI evidence for actionability/timeouts, you can attach the failure capture fixture:
172
164
 
173
165
  ```ts
174
166
  // tests/test.ts
@@ -185,24 +177,7 @@ Then import from that file in your specs:
185
177
  import { test, expect } from "./test";
186
178
  ```
187
179
 
188
- This improves the quality of:
189
-
190
- - blocked action diagnosis
191
- - assertion mismatch diagnosis
192
- - timeout explanations
193
- - DOM and state evidence in the report
194
-
195
- ## What `withSentinel()` Does
196
-
197
- - Preserves your existing reporter configuration
198
- - Injects a Playwright JSON reporter if one is missing
199
- - Sets sensible artifact defaults:
200
- - trace: `retain-on-failure`
201
- - screenshot: `only-on-failure`
202
- - video: `retain-on-failure`
203
- - Uploads the run to Sentinel at the end of the test run
204
-
205
- ## Options
180
+ ## Configuration Options
206
181
 
207
182
  ```ts
208
183
  withSentinel(config, {
@@ -215,12 +190,23 @@ withSentinel(config, {
215
190
  });
216
191
  ```
217
192
 
218
- ## Workspace
193
+ ## Troubleshooting
219
194
 
220
- If you want private run history, recurring issue tracking, and team access, sign up for a Sentinel workspace and set `SENTINEL_TOKEN`.
195
+ ### “POST /api/runs failed …”
221
196
 
222
- ```bash
223
- SENTINEL_TOKEN=your_project_ingest_token npx playwright test
224
- ```
197
+ - Check `SENTINEL_MODE` (offline skips uploads).
198
+ - If using a workspace token, confirm `SENTINEL_TOKEN` is correct.
199
+ - If a server schema changed, upgrade the reporter/uploader and/or run DB migrations for self-hosted deployments.
200
+
201
+ ### “Local report generation failed …”
202
+
203
+ Make sure Playwright produced:
204
+
205
+ - `playwright-report/report.json`
206
+ - `test-results/` (or your configured `outputDir`)
207
+
208
+ Then rerun with `SENTINEL_MODE=offline` to force local generation.
209
+
210
+ ## License
225
211
 
226
- Create a workspace at [sentinelqa.com/register](https://sentinelqa.com/register).
212
+ See [LICENSE](./LICENSE).