Skip to content

Commit

Permalink
feat: add name and classname formatters
Browse files Browse the repository at this point in the history
Closes #75
  • Loading branch information
Martin Leonhartsberger committed Dec 11, 2015
1 parent a95a93f commit 3f43c51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module.exports = function(config) {
outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: '', // suite will become the package name attribute in xml testsuite element
useBrowserName: true // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined // function (browser, result) to customize the classname attribute in xml testcase element
}
});
};
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for
var outputDir = reporterConfig.outputDir
var outputFile = reporterConfig.outputFile
var useBrowserName = reporterConfig.useBrowserName
var nameFormatter = reporterConfig.nameFormatter
var classNameFormatter = reporterConfig.classNameFormatter

var suites
var pendingFileWritings = 0
Expand Down Expand Up @@ -123,8 +125,9 @@ var JUnitReporter = function (baseReporterDecorator, config, logger, helper, for

this.specSuccess = this.specSkipped = this.specFailure = function (browser, result) {
var spec = suites[browser.id].ele('testcase', {
name: result.description, time: ((result.time || 0) / 1000),
classname: getClassName(browser, result)
name: typeof nameFormatter === 'function' ? nameFormatter(browser, result) : result.description,
time: ((result.time || 0) / 1000),
classname: (typeof classNameFormatter === 'function' ? classNameFormatter : getClassName)(browser, result)
})

if (result.skipped) {
Expand Down

0 comments on commit 3f43c51

Please sign in to comment.