Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@mmisty/cypress-allure-adapter
Advanced tools
cypress allure adapter to generate allure results during tests execution (Allure TestOps compatible)
This is allure adapter for Cypress providing realtime results. It is useful when using Allure TestOps - so you can watch tests execution. It adds tests, steps, suites and screenshots during tests execution.
In the same time you can generate Allure Report from these results and it will have all necessary fields.
Some settings were taken from @shelex/cypress-allure-plugin
Install adapter by npm i -D @mmisty/cypress-allure-adapter
Import @mmisty/cypress-allure-adapter/support
into your support/index.ts
file (or e2e.ts
file)
import '@mmisty/cypress-allure-adapter/support';
// import other custom ommands here
If you want all custom commands to be wrapped in report import adapter before adding(importing) any custom commands
Add allureAdapterSetup();
in your support/index.ts
file (or e2e.ts
file)
import { allureAdapterSetup } from '@mmisty/cypress-allure-adapter';
allureAdapterSetup();
If you want all custom commands to be correctly wrapped in report register adapter before adding custom commands:
import { allureAdapterSetup } from '@mmisty/cypress-allure-adapter';
allureAdapterSetup();
// register custom commands here
Add configureAllureAdapterPlugins(on, config);
into your plugins file:
// cypress.config.ts
import { configureAllureAdapterPlugins } from '@mmisty/cypress-allure-adapter/plugins';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
configureAllureAdapterPlugins(on, config);
return config;
},
// ...
}
});
In cypress.config.ts
or in your environment files set allure
env var to true
.
See other environment variables
No need to setup types - should be done automatically
That's it! :tada:
Variable | Description |
---|---|
allure type: boolean default: false | Enables reporting |
allureResults type: string default: allure-results | Path to allure results folder (where json files will be written) |
allureResultsWatchPath type: string default: allure-results | This is needed when using Allure TestOps: path to folder where results will be moved after all tests from spec are executed. This path is what you need to watch when using Allure TestOps, but default this is not specified. When you use this path test results will start to appear in Allure TestOps only after spec is finished. If do not use this with Allure TestOps some videos may not be uploaded - videos will be uploaded only for 1 test from spec file. |
allureLogCyCommands type: boolean default: true | log cypress commands, by default will log all |
allureSkipCommands type: string ex.: screenshot,wait | Commands separated with comma Will not log specified commands as steps in allure report, by default logs all commands |
allureWrapCustomCommands type: true/false/string default: true ex: - allureWrapCustomCommands: 'true' - allureWrapCustomCommands:'qaId,login' - allureWrapCustomCommands:'!qaValue' | will wrap custom commands, so custom command will have child steps in report When value has string with commands split by comma will wrap only these commands. To exclude commands specify them starting with ! - all commands specified in this variable should have either ! or not have it For this to work you should register allure plugin in setup files before any new commands are added. |
allureCleanResults type: boolean default: false | Will remove allure results on cypress start (it will be done once, after plugins are loaded) |
allureAttachRequests type: boolean default: false | Attach request/response body and status as files to request step Several requests: One request: |
allureCompactAttachments type: boolean default: true | Stringify requests attachments with spaces or not |
allureAddVideoOnPass type: boolean default: false | When true - will attach video for all tests (including passed), otherwise will attach videos only for failed, broken, unknown |
tmsPrefix type: string ex: http://jira.com or http://jira.com/PROJECT-1/*/browse | You can specify prefix to tms using this. It will be concatenated with value when using cypress interface like cy.allure().tms('PROJ-01') . Also link can be specified with * - it will be replaced with id. Difference between tms and issue - will have different icons: |
issuePrefix type: string ex: http://jira.com or http://jira.com/PROJECT-1/*/browse | The same as tmsPrefix - for issue cy.allure().issue('PROJ-02') |
allureShowDuplicateWarn type: boolean default: false | Show console warnings about test duplicates. |
tmsPrefix
and issuePrefix
- you can specify prefix to tms using this.
Also link can be specified with *
- it will be replced with id.
// cypress.config.ts
env: {
tmsPrefix: 'http://jira.com'
issuePrefix: 'http://jira.com/PROJECT-1/*/browse'
}
// test.spec.ts
cy.allure().tms('ABC-1'); // http://jira.com/ABC-1
cy.allure().issue('ABC-2'); // http://jira.com/PROJECT-1/ABC-2/browse
In order to see Allure Report you need to install the CLI.
For nodejs you can use allure-commandline:
npm i -D allure-commandline
After installed allure
command will be available.
To see a report in browser, run in console
allure serve
If you want to generate html version, run in console
allure generate
There is allure interface available to use from tests - cy.allure()
and Cypress.Allure
.
For details see interface
If you use Cypress action after:spec
in plugins you
can use the following configuration to have video attached to tests:
// cypress.config.ts
import { configureAllureAdapterPlugins } from '@mmisty/cypress-allure-adapter/plugins';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
const reporter = configureAllureAdapterPlugins(on, config);
on('after:spec', async (spec, results) => {
// your code in after spec
await reporter.afterSpec({ results });
})
return config;
},
// ...
}
});
Some operations like writing environment information, execution info or categories definitions should be done once for a run.
To do that you need to modify your setupNodeEvents function:
// cypress.config.ts
import { configureAllureAdapterPlugins } from '@mmisty/cypress-allure-adapter/plugins';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
const reporter = configureAllureAdapterPlugins(on, config);
// after that you can use allure to make operations on cypress start,
// or on before run start
on('before:run', details => {
reporter?.writeEnvironmentInfo({
info: {
os: details.system.osName,
osVersion: details.system.osVersion,
},
});
});
return config;
},
// ...
}
});
If you need to add labels, tags or other meta info for tests you can use the following additional events for Cypress.Allure interface:
test:started
is fired after tests started but before all "before each" hookstest:ended
is fired after all "after each" hooksCypress.Allure.on('test:started', test => {
Cypress.Allure.label('tag', 'started');
});
And also if you need to do something with test before it ends:
Cypress.Allure.on('test:ended', test => {
Cypress.Allure.label('tag', 'ended');
Cypress.Allure.step('before end step');
});
You can put this into your support/index.ts
file.
To see debug log run cypress with DEBUG env variable like: DEBUG=cypress-allure* npm run cy:open
0.9.0
FAQs
cypress allure adapter to generate allure results during tests execution (Allure TestOps compatible)
The npm package @mmisty/cypress-allure-adapter receives a total of 13,532 weekly downloads. As such, @mmisty/cypress-allure-adapter popularity was classified as popular.
We found that @mmisty/cypress-allure-adapter demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.