@serenity-js/cucumber
Version:
Serenity/JS test runner adapter for seamless integration with any version of Cucumber.js, facilitating BDD-style test automation and leveraging Serenity/JS reporting capabilities
52 lines • 1.45 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CucumberFormat = void 0;
const tiny_types_1 = require("tiny-types");
/**
* Represents a Cucumber.js formatter
*
* ## Learn more
*
* - [Cucumber formatters](https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#built-in-formatters)
*
* @group Integration
*/
class CucumberFormat {
value;
formatter;
output;
/**
* @param value
* Cucumber format expression, like `pretty` or `json:out.json`
*/
constructor(value) {
this.value = value;
[this.formatter, this.output] = CucumberFormat.split((0, tiny_types_1.ensure)('format', value, (0, tiny_types_1.isString)(), (0, tiny_types_1.isNotBlank)()));
}
/**
* See https://github.com/cucumber/cucumber-js/blob/master/src/cli/option_splitter.ts
*
* @param format
*/
static split(format) {
const parts = format.split(/([^A-Z]):(?!\\)/);
const result = parts.reduce((memo, part, i) => {
if (partNeedsRecombined(i)) {
memo.push(parts.slice(i, i + 2).join(''));
}
return memo;
}, []);
if (result.length === 1) {
result.push('');
}
return result;
}
}
exports.CucumberFormat = CucumberFormat;
/**
* @private
*/
function partNeedsRecombined(i) {
return i % 2 === 0;
}
//# sourceMappingURL=CucumberFormat.js.map
;