@andrii_kremlovskyi/playwright-traces-reader 1.1.1 → 1.1.2
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
|
@@ -90,13 +90,19 @@ console.log(`Error: ${summary.error?.message}`);
|
|
|
90
90
|
|
|
91
91
|
## API
|
|
92
92
|
|
|
93
|
-
### `getFailedTestSummaries(reportDataDir)`
|
|
93
|
+
### `getFailedTestSummaries(reportDataDir, options?)`
|
|
94
94
|
|
|
95
95
|
Report-level helper. Returns `TraceSummary[]` — one entry per **unique** failing test:
|
|
96
96
|
- Passing tests are skipped cheaply (no `getSummary` call).
|
|
97
97
|
- Retries are deduplicated by the full test title from `context-options`. The **last retry** (highest root step `endTime`) is used so the summary reflects the most recent execution.
|
|
98
98
|
- Pure API traces (no browser context) are deduplicated by `ctx.traceDir`.
|
|
99
99
|
|
|
100
|
+
**`GetFailedTestSummariesOptions`** (optional second argument):
|
|
101
|
+
|
|
102
|
+
| Option | Type | Default | Description |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| `excludeSkipped` | `boolean` | `false` | Omit tests that called `test.skip()` inside the test body. Detected by an error message starting with `"Test is skipped:"`. Pre-annotated skips (suite-level annotations or conditional `test.skip(condition)`) are already excluded automatically because they produce no root step failures. |
|
|
105
|
+
|
|
100
106
|
This is the recommended entry point for failure analysis. See [`TraceSummary`](#tracesummary) for the full field list.
|
|
101
107
|
|
|
102
108
|
### `getSummary(ctx)`
|
package/package.json
CHANGED
|
@@ -40,6 +40,16 @@ for (const f of failures) {
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
To exclude tests that were skipped via `test.skip()` inside the test body, pass `{ excludeSkipped: true }`:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { getFailedTestSummaries } from '@andrii_kremlovskyi/playwright-traces-reader';
|
|
47
|
+
|
|
48
|
+
const failures = await getFailedTestSummaries('/path/to/playwright-report/data', { excludeSkipped: true });
|
|
49
|
+
// in-body test.skip() calls are now excluded from the results
|
|
50
|
+
// pre-annotated skips (suite annotations / conditional test.skip(condition)) are always excluded
|
|
51
|
+
```
|
|
52
|
+
|
|
43
53
|
### 2. Inspect failure details
|
|
44
54
|
|
|
45
55
|
Each item returned by `getFailedTestSummaries()` is a `TraceSummary` — it already contains everything needed for failure analysis. No second call required.
|
|
@@ -359,7 +369,7 @@ Using a fixed, recognisable filename makes it easy to spot and clean up if the a
|
|
|
359
369
|
|
|
360
370
|
## Tips
|
|
361
371
|
|
|
362
|
-
- **Starting point for report-level failures**: Use `getFailedTestSummaries(dataDir)` — returns `TraceSummary[]` for every unique failing test with retries deduplicated and passing tests excluded. The returned `TraceSummary` already contains steps, API calls, and the DOM snapshot at failure.
|
|
372
|
+
- **Starting point for report-level failures**: Use `getFailedTestSummaries(dataDir)` — returns `TraceSummary[]` for every unique failing test with retries deduplicated and passing tests excluded. The returned `TraceSummary` already contains steps, API calls, and the DOM snapshot at failure. Pass `{ excludeSkipped: true }` to also exclude tests that called `test.skip()` inside the test body.
|
|
363
373
|
- **Starting point for per-context analysis**: Use `getSummary(ctx)` on a specific `TraceContext` from `listTraces()` — it gives `testTitle`, status, error, slowest steps, API calls, and the DOM snapshot closest to the failure in one call.
|
|
364
374
|
- **Accurate failure count**: `getFailedTestSummaries()` deduplicates by the full Playwright title (spec path + describe + test name from `context-options`), correctly identifying 13 unique tests even when 23 traces exist (10 failed × 2 retries + 3 flaky × 1 trace). Using root step titles (`f.title`) would under-count when different tests share the same `test.step()` description.
|
|
365
375
|
- **Drill into failures**: Each `TestStep` in `topLevelSteps` includes `.children`. Walk them recursively to find the specific assertion or action that failed within the test.
|