Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ For more advanced usage, there are several inputs available.
# Reports - Choose as many as you like. Default is false. Choosing none will use default reports.
summary-report: true
summary-delta-report: false
tests-changed-report: false
github-report: false
test-report: false
test-list-report: false
Expand Down
2 changes: 1 addition & 1 deletion __tests__/ctrf/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ describe('stripAnsi', () => {
// @ts-expect-error Testing runtime error
expect(() => stripAnsi({})).toThrow(TypeError)
})
})
})
1 change: 1 addition & 0 deletions __tests__/ctrf/report-preparation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ function createSingleReportInputs(): Inputs {
collapseLargeReports: false,
summaryReport: true, // Only 1 report enabled
summaryDeltaReport: false,
testsChangedReport: false,
githubReport: false,
testReport: false,
testListReport: false,
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ inputs:
description: 'Include the summary delta report.'
required: false
default: false
tests-changed-report:
description:
'Include the tests changed report showing added and removed tests.'
required: false
default: false
github-report:
description: 'Include the GitHub report.'
required: false
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 23 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions dist/reports/tests-changed-table.hbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 41 additions & 2 deletions docs/report-showcase.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ execution.

- [Report Showcase](#report-showcase)
- [Summary Report](#summary-report)
- [Summary Delta Report](#summary-delta-report)
- [GitHub Report](#github-report)
- [Test Report](#test-report)
- [Test List Report](#test-list-report)
Expand All @@ -17,6 +18,7 @@ execution.
- [Failed Folded Report](#failed-folded-report)
- [Previous Results Report](#previous-results-report)
- [Insights Report](#insights-report)
- [Tests Changed Report](#tests-changed-report)
- [Slowest Report](#slowest-report)
- [AI Report](#ai-report)
- [Skipped Report](#skipped-report)
Expand Down Expand Up @@ -80,8 +82,6 @@ Set the `summary-delta-report` input to true in your workflow configuration:
| --- | --- | --- | --- | --- | --- | --- |
| **58**    *↑2* | **58**    *±0* | **0**    *±0* | **0**    *±0* | **0**    *±0* | **0**    *±0* | **11.2s**    *↓2ms* |



## File Report

### Overview
Expand Down Expand Up @@ -711,6 +711,45 @@ Set the `insights-report` input to true in your workflow configuration:

<sub><i>Measured over 2 runs.</i></sub>

## Tests Changed Report

### Overview

Displays tests that have been added or removed compared to a baseline or previous run. This report helps track test suite evolution over time by showing exactly which tests are new and which have been removed. Each test is listed with its name and suite hierarchy, making it easy to identify changes in your test coverage.

Requires previous test results or a baseline for comparison.

### Usage

Set the `tests-changed-report` input to true in your workflow configuration:

```yaml
- name: Publish Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: './ctrf/*.json'
tests-changed-report: true
if: always()
```

---

**3 new tests added, 1 removed**

### Added ➕

| **Name** | **Suite** |
| --- | --- |
| should handle async operations correctly | API Tests > Authentication |
| should validate user input | API Tests > Validation |
| should cache results properly | Performance Tests |

### Removed ➖

| **Name** | **Suite** |
| --- | --- |
| deprecated legacy test | Legacy Suite > Old Tests |

## Slowest Report

### Overview
Expand Down
3 changes: 3 additions & 0 deletions src/core/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function getCliInputs(args: Arguments): Inputs {
collapseLargeReports: false,
summaryReport: args._.includes('summary'),
summaryDeltaReport: args._.includes('summary-delta'),
testsChangedReport: args._.includes('tests-changed'),
githubReport: args._.includes('github'),
testReport: args._.includes('tests'),
testListReport: args._.includes('test-list'),
Expand Down Expand Up @@ -105,6 +106,8 @@ export function getInputs(): Inputs {
summaryReport: core.getInput('summary-report').toLowerCase() === 'true',
summaryDeltaReport:
core.getInput('summary-delta-report').toLowerCase() === 'true',
testsChangedReport:
core.getInput('tests-changed-report').toLowerCase() === 'true',
testReport: core.getInput('test-report').toLowerCase() === 'true',
testListReport: core.getInput('test-list-report').toLowerCase() === 'true',
failedReport: core.getInput('failed-report').toLowerCase() === 'true',
Expand Down
18 changes: 8 additions & 10 deletions src/ctrf/core/src/methods/run-insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface SimplifiedTestData {
name: string
suite?: string[]
filePath?: string
line?: number
tags?: string[]
}

/**
Expand Down Expand Up @@ -720,7 +722,9 @@ function getTestsRemovedSinceBaseline(
return removedTests.map(test => ({
name: test.name,
suite: test.suite,
filePath: test.filePath
filePath: test.filePath,
line: test.line,
tags: test.tags
}))
}

Expand Down Expand Up @@ -753,7 +757,9 @@ function getTestsAddedSinceBaseline(
return addedTests.map(test => ({
name: test.name,
suite: test.suite,
filePath: test.filePath
filePath: test.filePath,
line: test.line,
tags: test.tags
}))
}

Expand Down Expand Up @@ -864,14 +870,6 @@ export function enrichReportWithInsights(
baseline
)

// Remove testsAdded and testsRemoved as they're not part of the official schema yet
if (baselineInsights.extra?.testsAdded) {
delete baselineInsights.extra.testsAdded
}
if (baselineInsights.extra?.testsRemoved) {
delete baselineInsights.extra.testsRemoved
}

return {
...currentReportWithTestInsights,
insights: baselineInsights
Expand Down
3 changes: 2 additions & 1 deletion src/ctrf/previous-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function shouldProcessPreviousResults(inputs: Inputs): boolean {
inputs.insightsReport ||
inputs.slowestReport ||
inputs.fetchPreviousResults ||
inputs.summaryDeltaReport
inputs.summaryDeltaReport ||
inputs.testsChangedReport
)
}

Expand Down
8 changes: 8 additions & 0 deletions src/github/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ function generateReportByType(
core.info('No AI analysis to display, skipping ai-report')
}
break
case 'tests-changed-report':
core.info('Adding tests changed report to summary')
addViewToSummary(
'### Test Changes',
BuiltInReports.TestsChangedTable,
report
)
break
case 'pull-request-report':
core.info('Adding pull request report to summary')
addViewToSummary('', BuiltInReports.PullRequest, report)
Expand Down
1 change: 1 addition & 0 deletions src/reports/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const DEFAULT_REPORT_ORDER: string[] = [
'flaky-rate-report',
'skipped-report',
'ai-report',
'tests-changed-report',
'pull-request-report',
'commit-report',
'slowest-report',
Expand Down
1 change: 1 addition & 0 deletions src/reports/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const basePath = getBasePath('reports');
export const BuiltInReports = {
SummaryTable: join(basePath, 'summary-table.hbs'),
SummaryDeltaTable: join(basePath, 'summary-delta-table.hbs'),
TestsChangedTable: join(basePath, 'tests-changed-table.hbs'),
TestTable: join(basePath, 'test-table.hbs'),
TestList: join(basePath, 'test-list.hbs'),
FailedTable: join(basePath, 'failed-table.hbs'),
Expand Down
26 changes: 26 additions & 0 deletions src/reports/tests-changed-table.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{#if (or (gt (length report.insights.extra.testsAdded) 0) (gt (length report.insights.extra.testsRemoved) 0))}}
**{{length report.insights.extra.testsAdded}} test{{#if (gt (length report.insights.extra.testsAdded) 1)}}s{{/if}} added, {{length report.insights.extra.testsRemoved}} removed**

{{#if (gt (length report.insights.extra.testsAdded) 0)}}
### Added ➕

| **Name** | **Suite** |
| --- | --- |
{{#each report.insights.extra.testsAdded}}
| {{name}} | {{#if suite}}{{join suite " > "}}{{else}}-{{/if}} |
{{/each}}
{{/if}}

{{#if (gt (length report.insights.extra.testsRemoved) 0)}}
### Removed ➖

| **Name** | **Suite** |
| --- | --- |
{{#each report.insights.extra.testsRemoved}}
| {{name}} | {{#if suite}}{{join suite " > "}}{{else}}-{{/if}} |
{{/each}}
{{/if}}
{{else}}
No changes to tests detected ✨
{{/if}}

Loading