Allure Reporter
A WebdriverIO reporter plugin to create Allure Test Reports.
Installation
The easiest way is to include @wdio/allure-reporter
as a devDependency in your package.json
.
{
"devDependencies": {
"@wdio/allure-reporter": "^7.0.0"
}
}
You can simply do it by:
npm install @wdio/allure-reporter --save-dev
Configuration
Configure the output directory in your wdio.conf.js file:
export const config = {
// ...
reporters: [['allure', {
outputDir: 'allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: true,
}]],
// ...
}
outputDir
defaults to./allure-results
. After a test run is complete, you will find that this directory has been populated with an.xml
file for each spec, plus a number of.txt
and.png
files and other attachments.disableWebdriverStepsReporting
- optional parameter(false
by default), in order to log only custom steps to the reporter.issueLinkTemplate
- optional parameter, in order to specify the issue link pattern. Reporter will replace{}
placeholder with value specified inaddIssue(value)
call parameter. The same logic is applied if Cucumber is used and tagissue
is set at any level, it will be converted to the link in the report. The parameter value example:https://example.org/issue/{}
tmsLinkTemplate
- optional parameter, in order to specify TMS (Test Management System) link pattern. Reporter will replace{}
placeholder with value specified inaddTestId(value)
call parameter. The same logic is applied if Cucumber is used and tagtestId
is set at any level, it will be converted to the link in the report. The parameter value example:https://example.org/tms/{}
disableWebdriverScreenshotsReporting
- optional parameter(false
by default), in order to not attach screenshots to the reporter.useCucumberStepReporter
- optional parameter (false
by default), set it to true in order to change the report hierarchy when using cucumber. Try it for yourself and see how it looks.disableMochaHooks
- optional parameter (false
by default), set it to true in order to not fetch thebefore/after
stacktrace/screenshot/result hooks into the Allure Reporter.addConsoleLogs
- optional parameter(false
by default), set to true in order to attach console logs from step to the reporter.reportedEnvironmentVars
(type:Record<string, string>
) - Set this option to display the environment variables in the report. Note that setting this, does not modify the actual environment variables.
Supported Allure API
addLabel(name, value)
- assign a custom label to testaddFeature(featureName)
– assign features to testaddStory(storyName)
– assign user story to testaddSeverity(value)
– assign severity to test, accepts one of these values: blocker, critical, normal, minor, trivialaddTag(value)
– assign a tag label to testaddEpic(value)
– assign an epic label to testaddOwner(value)
– assign an owner label to testaddSuite(value)
– assign a suite label to testaddSubSuite(value)
– assign a sub suite label to testaddParentSuite(value)
– assign a parent suite label to testaddIssue(value)
– assign issue id to testaddAllureId(value)
– assign allure test ops id label to testaddTestId(value)
– assign TMS test id to test- ~~
addEnvironment(name, value)
~~ – a deprecated function that no longer works. UsereportedEnvironmentVars
instead addAttachment(name, content, [type])
– save attachment to test.name
(String) - attachment name.content
– attachment content.type
(String, optional) – attachment MIME-type,text/plain
by default
addArgument(name, value)
- add an additional argument to testaddDescription(description, [type])
– add description to test.description
(String) - description of the test.type
(String, optional) – description type,text
by default. Values ['text', 'html','markdown']
addStep(title, [{content, name = 'attachment'}], [status])
- add step to test.title
(String) - name of the step.content
(String, optional) - step attachmentname
(String, optional) - step attachment name,attachment
by default.status
(String, optional) - step status,passed
by default. Must be "failed", "passed" or "broken"
startStep(title)
- start with a steptitle
(String) - name of the step.
endStep(status)
- end with a stepstatus
(String, optional) - step status,passed
by default. Must be "failed", "passed" or "broken"
step(name, body)
- starts step with content function inside. Allows to create steps with infinite hierarchybody
(Function) - the step body async function
Usage
Allure Api can be accessed using:
CJS
const allureReporter = require('@wdio/allure-reporter').default
ESM
import allureReporter from '@wdio/allure-reporter'
Mocha example
describe('Suite', () => {
it('Case', () => {
allureReporter.addFeature('Feature')
})
})
Cucumber
Basic Cucumber example:
Given('I include feature and story name', () => {
allureReporter.addFeature('Feature_name');
allureReporter.addStory('Story_name');
})