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:
parent
420038ca3b
commit
88d03cd26a
18
index.js
18
index.js
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// Copyright 2016 Hewlett-Packard Development Company, L.P.
|
// Copyright 2016 Hewlett-Packard Development Company, L.P.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
// 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 slug = config.slug || false;
|
||||||
var separator = config.separator || '.';
|
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;
|
var startTime, stream, file;
|
||||||
|
|
||||||
this.onRunStart = function(browsers) {
|
this.onRunStart = function(browsers) {
|
||||||
|
@ -40,10 +51,7 @@ function SubunitReporter(helper, logger, config) {
|
||||||
var parts = result.suite.slice();
|
var parts = result.suite.slice();
|
||||||
parts.push(result.description);
|
parts.push(result.description);
|
||||||
|
|
||||||
var testId = parts.join(separator);
|
var testId = normalizeFunction(parts).join(separator);
|
||||||
if (slug) {
|
|
||||||
testId = testId.replace(/\s+/g, '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
var status;
|
var status;
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
|
Loading…
Reference in New Issue