From 3efff7a27f481b4aa734654c01111e2926c53025 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Date: Sat, 20 Jul 2024 16:14:37 +0100 Subject: [PATCH 1/2] fix: add additional checks for no tests --- src/generate-report.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/generate-report.ts b/src/generate-report.ts index 687ca75..e18a611 100644 --- a/src/generate-report.ts +++ b/src/generate-report.ts @@ -120,9 +120,11 @@ class GenerateCtrfReport implements Reporter { this.ctrfReport.results.summary.stop = Date.now() if (this.suite !== undefined) { - this.processSuite(this.suite) + if (this.suite.allTests().length > 0) { + this.processSuite(this.suite) - this.ctrfReport.results.summary.suites = this.countSuites(this.suite) + this.ctrfReport.results.summary.suites = this.countSuites(this.suite) + } } this.writeReportToFile(this.ctrfReport) } @@ -138,13 +140,18 @@ class GenerateCtrfReport implements Reporter { } processTest(testCase: TestCase): void { + if (testCase.results.length === 0) { + return + } const latestResult = testCase.results[testCase.results.length - 1] - this.updateCtrfTestResultsFromTestResult( - testCase, - latestResult, - this.ctrfReport - ) - this.updateSummaryFromTestResult(latestResult, this.ctrfReport) + if (latestResult !== undefined) { + this.updateCtrfTestResultsFromTestResult( + testCase, + latestResult, + this.ctrfReport + ) + this.updateSummaryFromTestResult(latestResult, this.ctrfReport) + } } setFilename(filename: string): void { From 2fb125924e05b7715018d76d4bca09aa5a15a861 Mon Sep 17 00:00:00 2001 From: Matthew Thomas Date: Sat, 20 Jul 2024 16:15:31 +0100 Subject: [PATCH 2/2] chore: increment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 40c15de..e8e7746 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "playwright-ctrf-json-reporter", - "version": "0.0.14", + "version": "0.0.15", "description": "A Playwright JSON test reporter to create test results reports", "main": "dist/index.js", "scripts": {