testcafe-reporter-allure-expanded v1.1.0
testcafe-reporter-allure-expanded
This is the allure reporter plugin for TestCafe. This is used to generate allure visual reports for testcafe test execution.
This is an expansion of the npm package testcafe-reporter-allure created by Sintu Singh.
Adds videos to the reporter and cleans videos and screenshots afterwards. Also a bug from the original is fixed and the total test time is now shown correctly. You can greatly benefit from this package, only if you follow the instructions I wrote underneath. Don't expect this to work perfectly for every person, because my intention was never to share this publicly, but I found it easier to publish it on here for easy maintenance. I made this expansion because the original did not contain all the requirements for me. Having a video attached, was one of the must-haves. This package is meant for personal use and that is why you will see some specific meta-data, which fits my case the best. But of course you are free to use it for whatever you want. Please download the newest version and not previous ones, cause bugs are fixed in this version which have occured in previous versions.
Install
npm install testcafe-reporter-allure-expanded
Usage
When you run tests from the command line, specify the reporter name by using the --reporter
option:
testcafe chrome 'path/to/test/file.js' --reporter allure-expanded
When you use API, pass the reporter name to the reporter()
method:
testCafe
.createRunner()
.src('path/to/test/file.js')
.browsers('chrome')
.reporter('allure-expanded') // <-
.run();
When you use static configuration file 'testcaferc.json':
"reporter":
[
{
"name": "json",
"output": "Reports/report.json"
},
{
"name": "xunit",
"output": "Reports/report.xml"
},
{
"name": "allure-expanded"
}
],
Severities
The below severities are supported by this reporter.blocker, critical, normal, minor, trivial
Test meta data
To specify id, severity, user story, story_url or description, use test meta options.
User story
I recommand always adding an user story as meta data. Cause this meta data will be shown in the allure reporter under 'Feature by story'. Therefore a user story is needed. The MODULE metadata will be used as an epic in allure reporter. Try it out and you will see. The ID metadata will be concatenated with the Story link, so you get something like: https://jira.cloud.com/OB-0000 The BLOK metadata is just used for parameters in Allure. As I said in the start, this package is for personal use and some metadata is very specific for my case, like BLOK.
test
.meta({
ID: 'OB-0000',
TAG: 'List',
BLOK: 'SectionWithinAModule',
MODULE: 'ModuleOfAnApplication',
SEVERITY: 'critical',
USER_STORY: 'As user I want to be able to do...',
DESCRIPTION: 'Checks something',
("My Test", async (t) => {
// testcode
});
DESCRIPTION and USER_STORY in fixture meta
Metadata DESCRIPTION
and USER_STORY
can be specified in fixture meta. If user story or description is specified in fixture meta, it will discard the user story or description from test meta.
**** BLOK is the Dutch term for a 'section' and is smaller than a 'module' in the context of my company's software.
Environment
To add information to environment widget, just create environment.xml file to allure-results directory before report generation.
<environment>
<parameter>
<key>Browser</key>
<value>Chrome</value>
</parameter>
<parameter>
<key>Browser.Version</key>
<value>63.0</value>
</parameter>
<parameter>
<key>Stand</key>
<value>Production</value>
</parameter>
</environment>
Executor
To add an information about your test executor create a file executor.json in your allure-results:
{
"name": "Jenkins",
"type": "jenkins",
"url": "http://example.org",
"buildOrder": 1,
"buildName": "allure-report_deploy#1",
"buildUrl": "http://example.org/build#1",
"reportUrl": "http://example.org/build#1/AllureReport",
"reportName": "Demo allure report"
}
Configuration
To override default configurationn, create a doc-allure-config.js file in the root directory of your project and put below content in that file.
const DOC_ALLURE_CONFIG = {
CLEAN_REPORT_DIR: true,
COPY_HISTORY: false,
CLEAN_VIDEOS: true,
CLEAN_SCREENSHOTS: true,
RESULT_DIR: '/allure/allure-results',
REPORT_DIR: '/allure/allure-report',
META: {
TEST_ID: 'ID',
TAG: 'TAG',
BLOK: 'BLOK',
MODULE: 'MODULE',
SEVERITY: 'SEVERITY',
USER_STORY: 'USER_STORY',
DESCRIPTION: 'DESCRIPTION'
},
STORY_LABEL: 'Jira Story Link',
STORY_URL: 'https://jiraexample.cloud/browse/{{ID}}',
VIDEO_PATH: 'Videos/',
REPORTS_PATH: 'Reports/',
SCREENSHOT_PATH: 'Screenshots/',
CATEGORY_FILE_PATH: 'allure/',
labels: {
screenshotLabel: 'Screenshot',
videoLabel: 'Executie Video',
reportsLabel: 'Reports',
browserLabel: 'Browser',
userAgentLabel: 'User Agent',
allureStartMessage: 'Allure reporter started...',
allureClosedMessage: 'Allure reporter closed...'
}
};
module.exports = DOC_ALLURE_CONFIG;
Videos will be automatically added to the report. You can now choose if you want to clean the videos and screenshots afterwards (after they have already been copied from to the allure-results folder and have been therefore attached to the report), to prevent build up. You can do this by changing CLEAN_VIDEOS or CLEAN_SCREENSHOTS to true or false. Please change the VIDEO_PATH to your corresponding video path, otherwise it will automatically search videos at 'Videos/'.
Also the videos only work if your video options are according to the following configurations:
"videoPath": "Videos/",
"videoOptions": {
"singleFile": false,
"failedOnly": false,
"pathPattern": "${DATE}_${TIME}/${TEST}/${USERAGENT}/${FILE_INDEX}.mp4"
},
The same goes for screenshots:
"screenshots": {
"path": "Screenshots/",
"takeOnFails": true,
"pathPattern": "${DATE}_${TIME}/${TEST}/${USERAGENT}/${QUARANTINE_ATTEMPT}.png"
}
View report
After running testcafe tests, it should generate a folder allure/allure-results
in your project root directory.
Install allure-commandline module to your project.
npm install -g allure-commandline
Run below command to view allure report.
allure generate allure/allure-results --clean -o allure/allure-report && allure open allure/allure-report