Skip to content

Commit ae51c17

Browse files
Merge pull request #236 from PBMax02/failed-detailed-community-report
Failed detailed community report
2 parents 9bd3118 + 30de75c commit ae51c17

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Template Name: failed-detailed
2+
3+
## Description
4+
5+
The **failed-detailed** report focuses exclusively on failed test cases, providing a clear and detailed summary of each failure. For every failed test, the report includes the test name, the failure message, stack trace, code snippet, standard output, and standard error if available. This report is designed to help developers quickly diagnose and address issues providing the exact place where the failure occured. If there are no failing tests, the template will render **No failed tests 🎉** instead of the failed tests table.
6+
7+
---
8+
9+
## How to Use
10+
11+
Reference this template by its name in your workflow configuration:
12+
13+
```
14+
failed-detailed
15+
```
16+
17+
Then, add it to your workflow file as follows:
18+
19+
```yaml
20+
- name: Publish Test Report
21+
uses: ctrf-io/github-test-reporter@v1
22+
with:
23+
report-path: './ctrf/*.json'
24+
community-report: true
25+
community-report-name: failed-detailed
26+
if: always()
27+
```
28+
29+
Ensure your report JSON files are generated correctly and placed in the expected path.
30+
31+
> [!NOTE]
32+
> You can combine this report with the built-in reports by adding the `community-report` and `community-report-name` nodes to your existing workflow file.
33+
34+
## Important Considerations
35+
36+
- **JSON Structure:** Verify that your test results JSON conforms to the expected format, so that the template can correctly parse the summary values and test statuses.
37+
- **Custom Helpers:** This template utilizes custom helpers such as `getCtrfEmoji` and `formatTestMessagePreCode`. Make sure these are available in your environment.
38+
- **Conditional Rendering:** The detailed table of failed tests will only appear if there is at least one test with a `failed` status.
39+
40+
## What it Looks Like
41+
42+
43+
<table>
44+
<thead>
45+
<tr>
46+
<th>Failed Tests ❌</th>
47+
<th>Fail Message</th>
48+
</tr>
49+
</thead>
50+
<tbody>
51+
<tr>
52+
<td>should display title</td>
53+
<td>
54+
<details>
55+
<summary>Error: expect(page).toHaveTitle(expected) failed</summary>
56+
<p><strong>Trace:</strong></p>
57+
<pre><code>Error: expect(page).toHaveTitle(expected) failed<br>Expect "toHaveTitle" with timeout 5000ms
58+
9 × unexpected value "Fast and reliable end-to-end testing for modern web apps | Playwright"<br>&nbsp;&nbsp;&nbsp;&nbsp;at .\Projects\Playwright\tests\example.spec.ts:7:22</code></pre>
59+
<p><strong>Snippet:</strong></p>
60+
<pre><code> 5 |
61+
6 | // Expect a title "to contain" a substring.
62+
> 7 | await expect(page).toHaveTitle(/Playwright/);
63+
| ^
64+
8 | });
65+
9 |
66+
10 | test('should display title', async ({ page }) => {</code></pre>
67+
<p><strong>Standard Output:</strong></p>
68+
<pre><code>Navigated URL: https://playwright.dev/</code></pre>
69+
<p><strong>Standard Error:</strong></p>
70+
<pre><code>No standard error available</code></pre>
71+
</details>
72+
</td>
73+
</tr>
74+
</tbody>
75+
</table>
76+
77+
### OR
78+
79+
### No failed tests 🎉
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{#if ctrf.summary.failed}}
2+
<table>
3+
<thead>
4+
<tr>
5+
<th>Failed Tests {{getCtrfEmoji "failed"}}</th>
6+
<th>Fail Message</th>
7+
</tr>
8+
</thead>
9+
<tbody>
10+
{{#each ctrf.tests}}
11+
{{#if (eq status "failed")}}
12+
<tr>
13+
<td>{{getCtrfEmoji "failed"}} {{name}}</td>
14+
<td>
15+
<details>
16+
<summary>{{#if message}}{{formatTestMessagePreCode message true}}{{else}}No message available{{/if}}</summary>
17+
<p><strong>Trace:</strong></p>
18+
<pre><code>{{#if trace}}{{formatTestMessagePreCode trace true}}{{else}}No trace available{{/if}}</code></pre>
19+
<p><strong>Snippet:</strong></p>
20+
<pre><code>{{#if snippet}}{{formatTestMessagePreCode snippet true}}{{else}}No snippet available{{/if}}</code></pre>
21+
<p><strong>Standard Output:</strong></p>
22+
<pre><code>{{#if stdout}}{{formatTestMessagePreCode (join stdout "\n") true}}{{else}}No standard output available{{/if}}</code></pre>
23+
<p><strong>Standard Error:</strong></p>
24+
<pre><code>{{#if stderr}}{{formatTestMessagePreCode (join stderr "\n") true}}{{else}}No standard error available{{/if}}</code></pre>
25+
</details>
26+
</td>
27+
</tr>
28+
{{/if}}
29+
{{/each}}
30+
</tbody>
31+
</table>
32+
{{else}}
33+
<p>No failed tests ✨</p>
34+
{{/if}}

0 commit comments

Comments
 (0)