Allure Cucumber.js configuration
When setting up a project using Allure Cucumber.js (see How to start), you can add some configuration
options to the reporter.js
file. These options affect formatting of the error messages and processing of the Gherkin tags.
The options should be added into the third argument for the CucumberJSAllureFormatter
constructor. For example:
JavaScriptconst { CucumberJSAllureFormatter, AllureRuntime } = require("allure-cucumberjs");
const path = require("path");
class Reporter extends CucumberJSAllureFormatter {
constructor(options) {
super(
options,
new AllureRuntime({
resultsDir: path.resolve(__dirname, "allure-results"),
}),
{
exceptionFormatter: (message) => message.replace("qwerty123", "[password edited]"),
labels: [
{
pattern: [/@feature:(.*)/],
name: "epic",
},
{
pattern: [/@severity:(.*)/],
name: "severity",
},
],
links: [
{
pattern: [/@issue=(.*)/],
type: "issue",
urlTemplate: "https://example.com/issue/%s",
},
{
pattern: [/@tms=(.*)/],
type: "tms",
urlTemplate: "https://example.com/tms/%s",
},
],
},
);
}
}
module.exports = Reporter;
exceptionFormatter
The function that will process all exception messages before adding to the test report. Each time a test ends with an uncaught exception, Allure will call this function, passing the exception string as the argument. The function must return a string.
If not set, Allure will not use any processing of the exception messages, which is equivalent to using the anonymous function (message) => message
.
JavaScript{
exceptionFormatter: (message) => message.replace("qwerty123", "[pswrd edited]");
}
labels
List of rules for automatically adding labels based on Gherkin tags.
To define a rule, add to labels
an object with two properties:
pattern
: a list of regular expressions that will be used to select tags. Each pattern must include exactly one capture group.name
: the name of the labels that must be created when tags match the pattern. This label will be assigned the value captured by a regular expression.
For example, with the configuration below, the @level:minor
tag will produce a Severity label with the value “minor”.
JavaScript{
labels: [
{
pattern: [/@level:(.*)/],
name: "severity",
},
];
}
links
List of rules for automatically adding correct links based on Gherkin tags.
To define a rule, add to links
an object with three properties:
pattern
: a list of regular expressions that will be used to select tags. Each pattern must include exactly one capture group.type
: the type of the links that must be created when tags match the pattern.urlTemplate
: the template for generating link URLs. The template must include the%s
placeholder. It will be replaced with the value captured by a regular expression.
For example, with the configuration below, the @bug=123
tag will produce a link leading
to https://example.com/issue/123
. Allure will display the link with the appropriate
icon for the issue
type.
JavaScript{
links: [
{
pattern: [/@bug=(.*)/],
type: "issue",
urlTemplate: "https://example.com/issue/%s",
},
];
}