Allure Vitest configuration
The Allure Vitest adapter behavior can be affected by some configuration options set in your Vitest configuration file, e.g., vitest.config.ts
. For example:
import { defineConfig } from "vitest/config";
import { Status } from "allure-js-commons";
import { createRequire } from "node:module";
import * as os from "node:os";
const require = createRequire(import.meta.url);
export default defineConfig({
test: {
setupFiles: [require.resolve("allure-vitest/setup")],
reporters: [
"verbose",
[
"allure-vitest/reporter",
{
resultsDir: "allure-results",
links: {
issue: {
nameTemplate: "Issue #%s",
urlTemplate: "https://issues.example.com/%s",
},
tms: {
nameTemplate: "TMS #%s",
urlTemplate: "https://tms.example.com/%s",
},
jira: {
urlTemplate: "https://jira.example.com/browse/%s",
},
},
categories: [
{
name: "foo",
messageRegex: "bar",
traceRegex: "baz",
matchedStatuses: [Status.FAILED, Status.BROKEN],
},
],
environmentInfo: {
os_platform: os.platform(),
os_release: os.release(),
os_version: os.version(),
node_version: process.version,
},
},
],
],
},
});
resultsDir
Path to the directory where Allure Vitest will save the test results, see How it works. If the directory does not exist, it will be created. Defaults to allure-results
.
links
A mapping of templates that can be used to construct full URLs from short identifiers.
For each type of link (see allure.link()
), you can specify the following:
nameTemplate
— a template for generating the link name when it is not provided.urlTemplate
— a template for generating the link address when it is not provided.
Both templates must contain %s
at the position where the identifier should be placed.
For example, with the configuration above, await allure.issue("123")
will produce a link with the name Issue #123
and the address https://issues.example.com/
. Allure will display the link with the appropriate icon for the issue
type.
categories
Define custom categories that will be used to distinguish test results by their errors; see Defect 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.
environmentInfo
Key-value pairs that will be displayed on the report's main page, see Environment information.