Skip to content

Commit ab07417

Browse files
Merge pull request #116 from farid-zare/main
Community report
2 parents 61f8f70 + 0da292d commit ab07417

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ Add the following to your workflow file:
280280
with:
281281
report-path: './ctrf/*.json'
282282
community-report: true
283-
communty-reportn-name: summary-short
283+
communty-report-name: summary-short
284284
if: always()
285285
```
286286

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Template Name: cobra-report
2+
3+
## Description
4+
5+
The **cobra-report** template is designed to provide a concise overview of your test suite results. It displays key metrics including the total number of tests, passed tests, failed tests, and skipped tests. Additionally, when failures occur, it renders a detailed table listing each failed test along with its failure message. 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+
cobra-report
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+
communty-report-name: cobra-report
26+
if: always()
27+
```
28+
29+
Ensure your report JSON files are generated correctly and placed in the expected path.
30+
31+
## Important Considerations
32+
33+
- **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.
34+
- **Custom Helpers:** This template utilizes custom helpers such as `getCtrfEmoji`, `formatMessage`, and `anyFailedTests`. Make sure these are available in your environment.
35+
- **Conditional Rendering:** The detailed table of failed tests will only appear if there is at least one test with a `failed` status.
36+
37+
## What it Looks Like
38+
39+
### Summary Section
40+
41+
| **Tests 📝** | **Passed ✅** | **Failed ❌** | **Skipped ⏭️** |
42+
| --- | --- | --- | --- |
43+
| 5 | 3 | 1 | 1 |
44+
45+
### ❌ Some tests failed!
46+
47+
48+
<table>
49+
<thead>
50+
<tr>
51+
<th>Failed Tests </th>
52+
<th>Fail Message</th>
53+
</tr>
54+
</thead>
55+
<tbody>
56+
<tr>
57+
<td>test 1</td>
58+
<td>
59+
error message!
60+
</td>
61+
</tr>
62+
</tbody>
63+
</table>
64+
65+
### OR
66+
67+
### No failed tests 🎉
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
| **Tests 📝** | **Passed ✅** | **Failed ❌** | **Skipped ⏭️** |
2+
| --- | --- | --- | --- |
3+
| {{ctrf.summary.tests}} | {{ctrf.summary.passed}} | {{ctrf.summary.failed}} | {{ctrf.summary.skipped}} |
4+
5+
{{#if (anyFailedTests ctrf.tests)}}
6+
<table>
7+
<thead>
8+
<tr>
9+
<th>Failed Tests {{getCtrfEmoji "failed"}}</th>
10+
<th>Fail Message</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
{{#each ctrf.tests}}
15+
{{#if (eq status "failed")}}
16+
<tr>
17+
<td>{{getCtrfEmoji "failed"}} {{name}}</td>
18+
<td>
19+
{{#if message}}
20+
{{~{formatMessage message}}}
21+
{{else}}
22+
No failure message
23+
{{/if}}
24+
</td>
25+
</tr>
26+
{{/if}}
27+
{{/each}}
28+
</tbody>
29+
</table>
30+
{{else}}
31+
<p>No failed tests ✨</p>
32+
{{/if}}

0 commit comments

Comments
 (0)