Allure TestCafe configuration
The Allure TestCafe reporter accepts configuration options that control where results are written, how steps are captured, how links are formatted, and what additional data is included in the report.
Configuration is only available when using the runner API. When registering the reporter by name in a config file or on the CLI, the reporter runs with default settings.
To set options, pass a configuration object to createAllureTestCafeReporter():
const createTestCafe = require("testcafe");
const createAllureTestCafeReporter = require("testcafe-reporter-allure-official");
const { createAllureTestPlanFilter } = require("testcafe-reporter-allure-official/testplan");
const { Status } = require("allure-js-commons");
const os = require("node:os");
(async () => {
const testcafe = await createTestCafe();
try {
await testcafe
.createRunner()
.src(["tests/**/*.test.js"])
.browsers(["chromium:headless"])
.filter(createAllureTestPlanFilter())
.reporter(
createAllureTestCafeReporter({
resultsDir: "allure-results",
captureActionsAsSteps: true,
links: {
issue: {
nameTemplate: "Issue #%s",
urlTemplate: "https://issues.example.com/%s",
},
tms: {
nameTemplate: "TMS #%s",
urlTemplate: "https://tms.example.com/%s",
},
jira: {
urlTemplate: (v) => `https://jira.example.com/browse/${v}`,
},
},
categories: [
{
name: "Known flaky tests",
messageRegex: /timeout/,
matchedStatuses: [Status.BROKEN],
},
],
environmentInfo: {
os_platform: os.platform(),
os_release: os.release(),
node_version: process.version,
},
globalLabels: [{ name: "layer", value: "e2e" }],
}),
)
.run();
} finally {
await testcafe.close();
}
})();resultsDir
Path to the directory where the reporter will save test results, see How it works. If the directory does not exist, it will be created. Defaults to allure-results.
captureActionsAsSteps
If true (the default), the reporter automatically captures TestCafe actions and assertions as Allure steps. The following actions are captured:
- Navigation:
t.navigateTo() - Interactions:
t.click(),t.doubleClick(),t.rightClick(),t.hover(),t.drag(),t.dragToElement() - Input:
t.typeText(),t.selectText(),t.selectTextAreaContent(),t.pressKey(),t.setFilesToUpload(),t.clearUpload() - Scrolling:
t.scroll(),t.scrollBy(),t.scrollIntoView() - Frames and roles:
t.switchToIframe(),t.useRole() - Screenshots:
t.takeScreenshot(),t.takeElementScreenshot() - HTTP:
t.request() - Waits:
t.wait() - Assertions:
t.expect(...).eql(),t.expect(...).ok(), and other expect chains - Custom actions:
t.runCustomAction()
Automatic steps are nested under any enclosing explicit step created with allure.step(). When an assertion fails, the corresponding step is marked as failed with actual and expected values in the status details.
Set to false to disable automatic step capture:
createAllureTestCafeReporter({
captureActionsAsSteps: false,
});links
A mapping of templates that can be used to construct full URLs from short identifiers.
For each link type (see allure.link()), you can specify the following:
nameTemplate— a template or a function for generating the link name when it is not provided.urlTemplate— a template or a function for generating the link address when a short identifier is passed instead of a full URL.
The templates can be strings (with %s where the identifier should be placed) or functions (accepting the identifier and returning the result).
For example, with the configuration above, await allure.issue("AUTH-123", "Related issue") will produce a link with the name "Related issue" and the address https://issues.example.com/AUTH-123. If no name is passed, it defaults to Issue #AUTH-123.
Link templates can also be set via meta keys. A value in "allure.link.<type>" meta is treated as a raw URL or identifier that is processed through the matching template, if one is configured.
categories
Define custom categories that will be used to distinguish test results by their errors; see Categories.
This setting is an array, each item being an object representing one custom category. The objects may have the following properties:
name— a category name.messageRegex— a regular expression that the test result's message should match.traceRegex— a regular expression that the test result's trace should match.matchedStatuses— an array of statuses that the test result should be one of.flaky— whether the test result should be marked as flaky.description— a description shown in the categories panel for this category. Markdown is supported.descriptionHtml— an HTML description shown in the categories panel for this category.
This format is based on Allure's legacy categories file and is supported by all Allure Report versions. Allure Report 3 also provides a richer native category configuration — with label-based matching, grouping controls, transitions, and more — that is set directly in the Allure Report config file rather than in the reporter.
environmentInfo
Key-value pairs that will be displayed on the report's main page, see Environment information.
globalLabels
Labels applied to every test result in the run. Useful for tagging all results with a layer, team, or environment identifier without repeating it in every test.
Can be provided as an array of { name, value } label objects:
createAllureTestCafeReporter({
globalLabels: [
{ name: "layer", value: "e2e" },
{ name: "team", value: "frontend" },
],
});Or as a plain object mapping label names to values. A name can map to a single string or an array of strings:
createAllureTestCafeReporter({
globalLabels: {
layer: "e2e",
team: "frontend",
},
});createAllureTestPlanFilter
createAllureTestPlanFilter() accepts one optional option:
cwd— the directory used to resolve a relativeALLURE_TESTPLAN_PATH. Use this in monorepos where TestCafe does not run from the package root:
const { createAllureTestPlanFilter } = require("testcafe-reporter-allure-official/testplan");
module.exports = {
// ...
filter: createAllureTestPlanFilter({ cwd: __dirname }),
};