cypress-allure-adapter
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.
Note: Video uploads doesn't work well yet since video is being generated after all tests in spec are finished.
Some settings were taken from @shelex/cypress-allure-plugin
Installation
Install adapter by npm i -D @mmisty/cypress-allure-adapter
Setup:
-
Update support: add allureAdapterSetup();
in your support/index.ts
file (or e2e.ts
file)
import { allureAdapterSetup } from '@mmisty/cypress-allure-adapter';
allureAdapterSetup();
-
Update plugins: add configureAllureAdapterPlugins(on, config);
into your plugins file:
import { configureAllureAdapterPlugins } from '@mmisty/cypress-allure-adapter/plugins';
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
configureAllureAdapterPlugins(on, config);
return config;
},
}
});
-
Update environment variables: in cypress.config.ts
or in your env files:
-
allure
=> true
- will enable reporting
-
allureResults
=> allure-results
- path to allure-results (default 'allure-results')
-
allureResultsWatchPath
=> path to folder where results will be moved after spec is
done (if you use Allure TestOps specify this path to watch), but default this is not specified
When you use this path tests will start to appear in Allure TestOps only after spec is finished. If not use this with Allure
TestOps then some videos may not be uploaded. Will be uploaded only for 1 test from spec.
-
allureCleanResults
=> true
- will remove allure results on cypress start
-
allureSkipCommands
=> wrapNoLog,sync
- commands that will not be logged, separated with comma
-
allureAttachRequests
=> true
- attach request/response body and status
-
allureAddVideoOnPass
=> true
- attach video for all tests (including passed), otherwise attach only for failed, broken, unknown
-
allureShowDuplicateWarn
=> true
- show console warnings about test duplicates, default false
-
tmsPrefix
and issuePrefix
- you can specify prefix to tms using this.
Also link can be specified with *
- it will be replced with id.
env: {
tmsPrefix: 'http://jira.com'
issuePrefix: 'http://jira.com/PROJECT-1/*/browse'
}
cy.allure().tms('ABC-1');
cy.allure().issue('ABC-2');
EXAMPLE:
env: {
allure: 'true',
allureResults: 'allure-results',
allureCleanResults: 'true',
allureSkipCommands: 'wrapNoLog,sync', // separated comma
// ... other env varialbles
}
-
no need to setup types - should be done automatically
To see report
To see Allure report locally after tests were executed install allure-commandline
: npm i -D allure-commandline
and run command allure serve
Advanced
after:spec
If you are using Cypress action after:spec
in plugins you
can use the following configuration to have video attached to tests:
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) => {
await reporter.afterSpec({ results });
})
return config;
},
}
});
Start/End test events
If you need to add labels, tags or other meta info for tests you can use the following events:
test:started
is fired after tests started but before all "before each" hookstest:ended
is fired after all "after each" hooks
Cypress.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.
Allure Interface
The following commands available from tests with cy.allure()
or through Cypress.Allure
interface:
label(name: string, value: string): T;
startStep(name: string): T;
endStep(): T;
step(name: string): T;
tag(...tags: string[]): T;
severity(level: Severity): T;
thread(value: string): T;
fullName(value: string): T;
owner(value: string): T;
lead(value: string): T;
host(value: string): T;
layer(value: string): T;
browser(value: string): T;
device(value: string): T;
os(value: string): T;
epic(value: string): T;
link(url: string, name?: string, type?: LinkType): T;
tms(url: string, name?: string): T;
issue(url: string, name?: string): T;
feature(value: string): T;
story(value: string): T;
allureId(value: string): T;
language(value: string): T;
parameter(name: string, value: string): T;
parameters(...params: Parameter[]): T;
testParameter(name: string, value: string): T;
testStatus(result: Status, details?: StatusDetails): T;
testDetails(details: StatusDetails): T;
testAttachment(name: string, content: Buffer | string, type: ContentType): T;
testFileAttachment(name: string, file: string, type: ContentType): T;
attachment(name: string, content: Buffer | string, type: ContentType): T;
fileAttachment(name: string, file: string, type: ContentType): T;
addDescriptionHtml(value: string): T;
writeEnvironmentInfo(info: EnvironmentInfo): T;
writeExecutorInfo(info: ExecutorInfo): T;
writeCategoriesDefinitions(categories: Category[]): T;
deleteResults(): T;
Troubleshooting
To see debug log run cypress with DEBUG env variable like: DEBUG=cypress-allure* npm run cy:open
Change log
0.6.0
- setting to disable warning about duplicates
0.5.0
- fixes to attach videos by Allure TestOps
- setting to attach videos only for unsuccessfull results
- setting to attach requests
0.0.2
Initial version