-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for reporterAPI usage
This makes the reporter config the default and deprecates testResultsProcessor. Fixes #32 BREAKING CHANGE: Reporter API is the default, testResultsProcessor is deprecated.
- Loading branch information
1 parent
22d8c11
commit 93bdfe2
Showing
5 changed files
with
94 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
var builder = require('jest-trx-results-processor'); | ||
var builder = require("jest-trx-results-processor/dist/testResultsProcessor"); | ||
|
||
var processor = builder({ | ||
outputFile: 'relative/path/to/resulting.trx' // this defaults to "test-results.trx" | ||
outputFile: "relative/path/to/resulting.trx", // this defaults to "test-results.trx" | ||
}); | ||
|
||
module.exports = processor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import { AggregatedResult } from "@jest/test-result"; | ||
import { Config } from "@jest/types"; | ||
import { writeFileSync } from "fs"; | ||
import { generateTrx, IOptions } from "./trx-generator"; | ||
|
||
const processor = ( | ||
options: IOptions = { | ||
outputFile: "test-results.trx", | ||
defaultUserName: "anonymous", | ||
}, | ||
) => (testRunResult: AggregatedResult): AggregatedResult => { | ||
process.stdout.write("Generating TRX file..."); | ||
class TrxReporter { | ||
constructor( | ||
_: Config.GlobalConfig, | ||
private options: IOptions = { | ||
outputFile: "test-results.trx", | ||
defaultUserName: "anonymous", | ||
}, | ||
) {} | ||
|
||
const trx = generateTrx(testRunResult, options); | ||
public onRunComplete = ( | ||
_: any, | ||
aggregatedResults: AggregatedResult, | ||
): Promise<void> | void => { | ||
const trx = generateTrx(aggregatedResults, this.options); | ||
|
||
writeFileSync(options.outputFile, trx, { encoding: "utf8" }); | ||
process.stdout.write("DONE\n"); | ||
process.stdout.write(`TRX file output to '${options.outputFile}'\n`); | ||
writeFileSync(this.options.outputFile, trx, { encoding: "utf8" }); | ||
process.stdout.write("DONE\n"); | ||
process.stdout.write(`TRX file output to '${this.options.outputFile}'\n`); | ||
} | ||
} | ||
|
||
// Return the input testRunResult to allow for chaining other result processors | ||
return testRunResult; | ||
}; | ||
|
||
export = processor; | ||
module.exports = TrxReporter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AggregatedResult } from "@jest/test-result"; | ||
import { writeFileSync } from "fs"; | ||
import { generateTrx, IOptions } from "./trx-generator"; | ||
|
||
const processor = ( | ||
options: IOptions = { | ||
outputFile: "test-results.trx", | ||
defaultUserName: "anonymous", | ||
}, | ||
) => (testRunResult: AggregatedResult): AggregatedResult => { | ||
process.stdout.write("Generating TRX file..."); | ||
|
||
const trx = generateTrx(testRunResult, options); | ||
|
||
writeFileSync(options.outputFile, trx, { encoding: "utf8" }); | ||
process.stdout.write("DONE\n"); | ||
process.stdout.write(`TRX file output to '${options.outputFile}'\n`); | ||
|
||
// Return the input testRunResult to allow for chaining other result processors | ||
return testRunResult; | ||
}; | ||
|
||
export = processor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters