Links
In Allure reports, you can add different types of links to your test cases for better context and traceability, e.g.:
- links to issues in your issue tracker (e.g. JIRA, GitHub, etc.);
- links to test cases in your Test Management System (TMS);
- links to any custom URL.
There are two ways to add links to your test cases:
- declaratively, using JSDoc annotations such as
@link
,@issue
, and@tms
; - programmatically, using annotation functions from the 'jest-allure2-reporter/api' package such as
$Link
,$Issue
, and$TmsLink
.
Issue Links
You can link an issue in your issue tracker to a test case.
- Docblocks
- DSL
- Preview
it('should validate non-ASCII passwords', () => {
/**
* A customer ticket from our Support team.
* @issue AUTH-123
*/
/* ... test code ... */
});
import { $Issue } from 'jest-allure2-reporter/api';
// A customer ticket from our Support team.
$Issue('AUTH-123');
it('should validate non-ASCII passwords', () => {
/* ... test code ... */
});
TODO: add screenshot
TMS Links
You can link a test case in your Test Management System (TMS) to a test case as shown below.
- Docblocks
- DSL
- Preview
it('should be connected to TMS', () => {
/**
* @tms TMS-123
*/
/* ... test code ... */
});
import { $TmsLink } from 'jest-allure2-reporter/api';
$TmsLink('TMS-123');
it('should be connected to TMS', () => {
/* ... */
});
TODO: add screenshot
Custom Links
You can link an arbitrary URL to a test case:
- Docblocks
- DSL
- Preview
it('should demonstrate how the links work', () => {
/**
* @link https://example.com/custom
*/
/* ... test code ... */
});
import { $Link } from 'jest-allure2-reporter/api';
$Link('https://example.com/custom');
it('should demonstrate how the links work', () => {
/* ... */
});
TODO: add screenshot
Advanced users can also specify a custom link type and configure the URL pattern for it.
- Docblocks
- DSL
- Preview
it('should demonstrate how the links work', () => {
/**
* @link docs features/links
*/
/* ... test code ... */
});
import { $Link } from 'jest-allure2-reporter/api';
$Link('docs', 'features/links');
it('should demonstrate how the links work', () => {
/* ... */
});
TODO: add screenshot
Configuration
To handle link generation for custom link types, TMS, and issue ids, you need to configure the 'jest-allure2-reporter' in your jest.config.js
file.
You can specify URL patterns for each type of link. When generating the Allure report, the annotation function or JSDoc will replace the ID in the URL pattern with the actual ID provided in your test case.
Below is an example configuration:
module.exports = {
reporters: [
[
"jest-allure2-reporter",
{
issueLinkTemplate: "http://your-tracker.com/issue/{}",
tmsLinkTemplate: "http://your-tms.com/case/{}",
customLinkTemplate: "https://your-custom-url/{}"
}
]
]
}
In this example, {}
will be replaced with the issue id, tms id, or custom id you've specified