People
In Allure reports, you can indicate who is the owner of any given test case. This allows for better organization, responsibility allocation, and communication within your team. Advanced solutions can leverage this information to notify the relevant people about test failures or to assign automatic tasks to them.
There are two ways to associate a test case with a person:
- declaratively, via
@owner
JSDoc annotations; - programmatically, via
$Owner
annotation functions.
Basic usage
The owner of a test suite is the person who is responsible for the test suite and all test cases in it.
Here is how you can associate an entire test file with an owner:
- Docblocks
- DSL
/**
* @owner John Doe <john.doe@example.com>
*/
describe('Sanity: Login flow', () => {
it('should login with valid credentials', () => {
/* ... test code ... */
});
});
describe('Sanity: Dashboard', () => {
it('should show the dashboard', () => {
/* ... test code ... */
});
});
import { allure } from 'jest-allure2-reporter/api';
allure.owner('John Doe <john.doe@example.com>');
describe('Sanity: Login flow', () => {
it('should login with valid credentials', () => {
/* ... test code ... */
});
});
describe('Sanity: Dashboard', () => {
it('should show the dashboard', () => {
/* ... test code ... */
});
});
Here is how you can associate a selected test suite with an owner:
- Docblocks
- DSL
describe('Sanity: Login flow', () => {
/**
* @owner John Doe <john.doe@example.com>
*/
it('should login with valid credentials', () => {
/* ... test code ... */
});
});
Please note that you have to put the JSDoc comment inside the test suite function body.
import { $Owner } from 'jest-allure2-reporter/api';
$Owner('John Doe <john.doe@example.com>');
describe('Sanity: Login flow', () => {
it('should login with valid credentials', () => {
/* ... test code ... */
});
});
You can also assign an owner for each test case individually.
- Docblocks
- DSL
it('should login with valid credentials', () => {
/**
* @owner John Doe <john.doe@example.com>
*/
/* ... test code ... */
});
Please note that you have to put the JSDoc comment inside the test function body.
$Owner('John Doe <john.doe@example.com>');
it('should login with valid credentials', () => {
/* ... */
});
Examples
In the generated report, the owner is displayed in the test case description:
TODO: add screenshot
Advanced usage
You can use the owner information in your custom reporters and plugins.
TODO: read more about query functions to use in your custom reporters and plugins
import * as query from 'jest-allure2-reporter/query';
/**
* Simplistic implementation of a notification reporter.
* @implements {Reporter}
*/
export default class NotifyJestReporter {
/**
*/
async onRunComplete(contexts, results) {
const owners = new Set();
for (const testFileResult of results.testResults) {
for (const testCaseResult of testFileResult.testResults) {
if (testCaseResult.status === 'failed') {
const owner = query.owner(testCaseResult);
if (owner) {
owners.add(owner);
}
}
}
}
for (const owner of owners) {
await this.#notify(owner);
}
}
async #notify(person) {
// ... some code to send a notification to the person ...
}
}