Support custom testId normalization functions

This adds support for user-specified normalization functions as a
configuration paramter 'normalize'. These functions can override the
default default normalization functionality (as configured with the
'slug' parameter) to adjust or remove project-specific formatting.
This commit is contained in:
Tim Buckley 2016-06-09 12:01:34 -06:00
parent 420038ca3b
commit 88d03cd26a
1 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,3 @@
// Copyright 2016 Hewlett-Packard Development Company, L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -24,6 +23,18 @@ function SubunitReporter(helper, logger, config) {
var slug = config.slug || false;
var separator = config.separator || '.';
function normalize(parts) {
if (slug) {
return parts.map(function(part) {
return part.replace(/\s+/g, '_');
});
} else {
return parts;
}
}
var normalizeFunction = config.normalize || normalize;
var startTime, stream, file;
this.onRunStart = function(browsers) {
@ -40,10 +51,7 @@ function SubunitReporter(helper, logger, config) {
var parts = result.suite.slice();
parts.push(result.description);
var testId = parts.join(separator);
if (slug) {
testId = testId.replace(/\s+/g, '_');
}
var testId = normalizeFunction(parts).join(separator);
var status;
if (result.success) {