
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
cypress-allure-upgraded
Advanced tools
Plugin for integrating allure reporter in Cypress with support of Allure API.
Allure binary: directly from allure2 or allure-commandline npm package.
Java 8 (required to run allure binary)
There is no need to set this plugin as reporter in Cypress or use any other allure reporters. Just download:
yarn add -D @shelex/cypress-allure-plugin
npm i -D @shelex/cypress-allure-plugin
Connect plugin in cypress/plugins/index.js
. Take into account that Cypress generate plugins file with module.exports
on the first initialization but you should have only one export section. In order to add Allure writer task just replace it or add writer task somewhere before returning config:
const allureWriter = require('@shelex/cypress-allure-plugin/writer');
// import allureWriter from "@shelex/cypress-allure-plugin/writer";
module.exports = (on, config) => {
allureWriter(on, config);
return config;
};
module.exports = (on, config) => {
on('file:preprocessor', webpackPreprocessor);
allureWriter(on, config);
return config;
};
Register commands in cypress/support/index.js
file:
import
:import '@shelex/cypress-allure-plugin';
require
:require('@shelex/cypress-allure-plugin');
for IntelliSense (autocompletion) support in your IDE add on top of your cypress/plugins/index.js
file:
/// <reference types="@shelex/cypress-allure-plugin" />
"include": [
"../node_modules/@shelex/cypress-allure-plugin/reporter",
"../node_modules/cypress"
]
Plugin is customizable via Cypress environment variables:
env variable name | description | default |
---|---|---|
allure | enable Allure plugin | false |
allureResultsPath | customize path to allure results folder | allure-results |
tmsPrefix | just a prefix substring or pattern with * for links from allure API in tests to test management system | `` |
issuePrefix | prefix for links from allure API in tests to bug tracking system | `` |
allureLogCypress | log cypress chainer (commands) and display them as steps in report | true |
allureLogGherkin | log gherkin steps from cucumber-preprocessor | inherits allureLogCypress value if not specified directly |
allureAttachRequests | attach cy.request headers, body, response headers, respose body to step automatically | false |
allureOmitPreviousAttemptScreenshots | omit screenshots attached in previous attempts when retries are used | false |
allureSkipAutomaticScreenshots | do not add screenshots automatically (for those who uses custom scripts, etc.) | false |
allureClearSkippedTests | remove skipped tests from report | false |
allureAddAnalyticLabels | add framework and language labels to tests (used for allure analytics only) | false |
allureAddVideoOnPass | attach video to report for passed tests | false |
This options could be passed:
via cypress.json
{
"env": {
"allureResultsPath": "someFolder/results",
// tms prefix used without `*`, equivalent to `https://url-to-bug-tracking-system/task-*`
"tmsPrefix": "https://url-to-bug-tracking-system/task-",
"issuePrefix": "https://url-to-tms/tests/caseId-"
// usage: cy.allure().issue('blockerIssue', 'AST-111')
// result: https://url-to-bug-tracking-system/task-AST-111
}
}
via command line
:
as Cypress environment variables are used please take into account that cli should have only one argument --env
or -e
, otherwise values will not be passed
```bash
yarn cypress run --env allure=true,allureResultsPath=someFolder/results
yarn cypress run --env TAGS='@smoke',allure=true
# for windows:
yarn cypress run --env "TAGS=@smoke","allure=true"
```
via Cypress environment variables
:
Cypress.env('issuePrefix', 'url_to_bug_tracker');
via allure.properties
file (but you still need to enable allure by passing allure=true
to cypress env variables):
allure.results.directory=custom_dir
allure.link.issue.pattern=https://example.com/task_
allure.link.tms.pattern=https://example.com/test_case_
allure.cypress.log.commands=true
allure.cypress.log.requests=true
allure.cypress.log.gherkin=true
allure.omit.previous.attempt.screenshot=true
allure.analytics=false
allure.video.passed=false
be sure your docker or local browser versions are next: Chrome 71+, Edge 79+. Firefox 65+
plugin might not be applied to older Cypress versions, 4+ is recommended
to enable Allure results writing just pass environment variable allure=true
, example:
npx cypress run --env allure=true
Cypress.Allure.reporter.runtime.writer;
localStorage.debug = 'allure-plugin*'
in DevTools consoleDEBUG=allure-plugin*
before cypress run\open commandSee cypress-allure-plugin-example project, which is already configured to use this plugin, hosting report as github page and run by github action. It has configuration for basic allure history saving (just having numbers and statuses in trends and history).
For complete history (allure can display 20 build results ) with links to older reports and links to CI builds check cypress-allure-historical-example with basic and straightforward idea how to achieve it.
There are also existing solutions that may help you prepare your report infrastructure:
Assuming allure is already installed:
allure serve
allure generate
allure open
There are three options of using allure api inside tests:
Cypress.Allure.reporter.getInterface()
- synchronousconst allure = Cypress.Allure.reporter.getInterface();
allure.feature('This is our feature');
allure.epic('This is epic');
allure.issue('google', 'https://google.com');
cy.allure()
- chainercy.allure()
.feature('This is feature')
.epic('This is epic')
.issue('google', 'https://google.com')
.parameter('name', 'value')
.tag('this is nice tag', 'as well as this');
@AS_ID("id_of_test_for_testops")
@parentSuite("someParentSuite")
@suite("someSuite")
@subSuite("someSubSuite")
@epic("thisisepic")
@feature("nice")
@story("cool")
@severity("critical")
@owner("IAMOwner")
@issue("jira","JIRA-1234")
@tms("tms","TC-1234")
@link("other","url")
@someOtherTagsWillBeAddedAlso
Scenario: Here is scenario
...
Allure API available:
It is posible to pass tms link or issue link with tags tms("ABC-111")
and issue("ABC-222")
.
However, that will not work well with Scenario Outlines which may have different examples being linked to different tasks or test cases in tms.
So, plugin will also parse your scenario outlines with examples and in case header in table will be tms
or issue
- it will add it as link to report.
Scenario Outline: Some scenario
Given User want to link test <number> to tms
When User creates examples table with tms and issue headers
Then Links will be added to allure
Examples:
| tms | issue | number |
| TEST-1 | JIRA-11 | 1 |
| TEST-2 | JIRA-22 | 2 |
In case you are using VS Code and Cypress Helper extension, it has configuration for allure cucumber tags autocompletion available:
"cypressHelper.cucumberTagsAutocomplete": {
"enable": true,
"allurePlugin": true,
"tags": ["focus", "someOtherTag"]
}
Screenshots are attached automatically, for other type of content feel free to use testAttachment
(for current test), attachment
(for current executable), fileAttachment
(for existing file).
Videos are attached for failed tests only from path specified in cypress config videosFolder
and in case you have not passed video=false
to Cypress configuration.
In case you want to attach videos for passed tests please use allureAddVideoOnPass=true
env variable.
Videos are quite tricky as Cypress has no events which we can use to catch event with video name as it is processed when test runner itself (cy) has closed. As a workaround we can add video link before even video is saved and then we have two options:
videosFolder
is set as allure-results
(or custom value you can pass as allureResultsPath
) in cypress.json or configuration options.
in this case video is written directly in allure-results and will be linked by name.videosFolder
is outside allure-results
relative path from allure-report
to videosFolder
will be added.Please take into account, that in case spec files have same name, cypress is creating subfolders in videos folder, and it is not handled from plugin unfortunately, so video may not have correct path in such edge case.
As Cypress has released After Spec API now this event could be evaluated for attachments. Now it will be used for:
experimentalRunEvents
enabledexperimentalInteractiveRunEvents
enabled
When one of this conditions is satisfied - after:spec
event will be used for attachments. It will reliably copy all screenshots available for each test and video (if available) to your allure-results
folder and attach to each of your tests, so you don't need to somehow upload your videos and configure paths, etc.Commands are producing allure steps automatically based on cypress events and are trying to represent how code and custom commands are executed with nested structure.
Moreover, steps functionality could be expanded with:
cy.allure().step('name')
- will create step "name" for current test. This step will be finished when next such step is created or test is finished.cy.allure().step('name', false)
OR cy.allure().logStep('name')
- will create step "name" for current parent step/hook/test. Will be finished when next step is created or test finished.cy.allure().startStep('name')
- will create step "name" for current cypress command step / current step / current parent step / current hook or test. Is automatically finished on fail event or test end, but I would recommend to explicitly mention cy.allure().endStep()
which will finish last created step.yarn test:prepare:basic
- generate allure results for tests in cypress/integration/basic
folderyarn test:prepare:cucumber
- generate allure results for tests in cypress/integration/cucumber
foldertest
- run tests from cypress/integration/results
against these allure resultsA lot of respect to Sergey Korol who made Allure-mocha reporter. Base integration with Cypress internal mocha runner is based on that solution.
Copyright 2020-2021 Oleksandr Shevtsov ovr.shevtsov@gmail.com.
This project is licensed under the Apache 2.0 License.
FAQs
allure reporting plugin for cypress
The npm package cypress-allure-upgraded receives a total of 2 weekly downloads. As such, cypress-allure-upgraded popularity was classified as not popular.
We found that cypress-allure-upgraded demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.