wdio-ctrf-json-reporter
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -24,8 +24,6 @@ import WDIOReporter, { type TestStats } from '@wdio/reporter'; | ||
private readonly defaultOutputDir; | ||
private filename; | ||
private testStats; | ||
constructor(reporterOptions: ReporterConfigOptions); | ||
onRunnerStart(): void; | ||
onTestEnd(testStats: TestStats): void; | ||
onRunnerEnd(): void; | ||
onRunnerEnd(runner: any): void; | ||
private setFilename; | ||
@@ -32,0 +30,0 @@ private updateCtrfTotalsFromTestStats; |
@@ -13,3 +13,2 @@ "use strict"; | ||
this.defaultOutputDir = 'ctrf'; | ||
this.filename = this.defaultOutputFile; | ||
this.reporterConfigOptions = { | ||
@@ -63,13 +62,17 @@ outputFile: (_a = reporterOptions === null || reporterOptions === void 0 ? void 0 : reporterOptions.outputFile) !== null && _a !== void 0 ? _a : this.defaultOutputFile, | ||
} | ||
onRunnerEnd() { | ||
onRunnerEnd(runner) { | ||
this.ctrfReport.results.summary.stop = Date.now(); | ||
const specFilePath = runner.specs[0]; | ||
const pathParts = specFilePath.split(path.sep); | ||
const uniqueIdentifier = pathParts.slice(-2).join('-').replace(/\.(js|ts)$/, ''); | ||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); | ||
this.reporterConfigOptions.outputFile = `report-${uniqueIdentifier}-${timestamp}.json`; | ||
this.writeReportToFile(this.ctrfReport); | ||
console.log(JSON.stringify(this.reporterConfigOptions)); | ||
} | ||
setFilename(filename) { | ||
if (filename.endsWith('.json')) { | ||
this.filename = filename; | ||
this.reporterConfigOptions.outputFile = filename; | ||
} | ||
else { | ||
this.filename = `${filename}.json`; | ||
this.reporterConfigOptions.outputFile = `${filename}.json`; | ||
} | ||
@@ -76,0 +79,0 @@ } |
{ | ||
"name": "wdio-ctrf-json-reporter", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -73,3 +73,3 @@ # Webdriverio JSON Reporter | ||
You'll find a JSON file named `ctrf-report.json` in the `ctrf` directory. | ||
In the `ctrf` directory, you will find the JSON report files generated for each spec. | ||
@@ -76,0 +76,0 @@ ## Reporter Options |
13524
185