Skip to content

Commit 829c402

Browse files
authored
Merge pull request #4 from strawberry-graphql/agent/add-html-coverage-report
Add HTML coverage reports
2 parents 3e397b2 + dfbc0b5 commit 829c402

8 files changed

Lines changed: 1657 additions & 62 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ __pycache__/
1212
build/
1313
dist/
1414
htmlcov/
15+
htmlstrawberry/

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ The package registers itself with pytest through the `pytest11` entry point and
2020
includes the project automation needed to test and publish future plugin
2121
features. It does not expose fixtures, hooks, or command-line options yet.
2222

23-
This release was contributed by [@patrick91](https://github.com/patrick91) in [#2](https://github.com/strawberry-graphql/pytest-strawberry/pull/2)
23+
This release was contributed by [@patrick91](https://github.com/patrick91) in [#2](https://github.com/strawberry-graphql/pytest-strawberry/pull/2)

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ Enable coverage on the pytest command line:
2424
pytest --strawberry-coverage
2525
```
2626

27-
By default, the report covers fields with explicit Strawberry resolvers or
28-
custom field resolution supplied by integrations such as Strawberry Django. It
29-
excludes fields handled only by Strawberry's ordinary attribute lookup:
27+
By default, the report covers fields with explicit Strawberry resolvers,
28+
runtime field extensions, or custom field resolution supplied by integrations
29+
such as Strawberry Django. It excludes fields handled only by Strawberry's
30+
ordinary attribute lookup:
3031

3132
```text
3233
============================= Strawberry coverage =============================
@@ -68,9 +69,37 @@ pytest --strawberry-coverage --strawberry-coverage-fail-under=90
6869
```
6970

7071
The threshold is compared with the displayed percentage rounded to two decimal
71-
places. Mode and threshold options require `--strawberry-coverage`.
72+
places. Mode, threshold, and HTML options require `--strawberry-coverage`.
7273

73-
Schema executions with different eligible fields or Python mappings receive
74+
### HTML report
75+
76+
Write the same coverage data to a self-contained HTML report:
77+
78+
```shell
79+
pytest --strawberry-coverage --strawberry-coverage-html=htmlstrawberry
80+
```
81+
82+
Open `htmlstrawberry/index.html` in a browser. The responsive report opens
83+
with the overall percentage, uses Python-first names, and groups compact
84+
single-line field rows under their type. Clear green and red rows distinguish
85+
covered and missing fields, and missing fields are also labeled in text so the
86+
state survives printing. In resolver mode, fields using ordinary attribute
87+
lookup can be shown as muted yellow-gray `not counted` rows for context while
88+
remaining excluded from coverage totals. Checkboxes can hide fully covered
89+
types or reveal those excluded fields without JavaScript. For declarations
90+
inside the pytest project root, the type header shows the Python file and each
91+
field shows its definition line.
92+
93+
Fields wired through an external resolver, resolver factory, lambda, or
94+
user-defined field extension also include a compact `via ...` hint. Ordinary
95+
inline methods and framework-generated fields remain unannotated, keeping the
96+
report focused on wiring that may not be obvious from Python source coverage.
97+
The report follows the operating system's light or dark appearance and includes
98+
all styles without external assets. Column labels and the current type remain
99+
visible while scrolling long reports. A custom output directory can be passed
100+
after `=`. The terminal report remains enabled.
101+
102+
Schema executions with different field sets or Python mappings receive
74103
separate fingerprinted tables. Executions with the same field set are combined.
75104
The final threshold uses their combined field and hit totals. Coverage from
76105
pytest-xdist workers is merged automatically.

RELEASE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
release type: minor
3+
---
4+
5+
Add a self-contained, responsive HTML reporter for Strawberry field coverage
6+
with an overall score, compact single-line Python-first type and field rows,
7+
covered and missing row states with explicit missing labels, sticky scanning
8+
context, user-defined extension coverage, non-obvious resolver wiring,
9+
schema-definition locations, CSS-only report filters, muted yellow-gray
10+
not-counted default fields, threshold status, dark mode, print styles, and
11+
pytest-xdist aggregation.

0 commit comments

Comments
 (0)