Parameters
Utilize parameterized testing to avoid code duplication and reduce your maintenance costs:
import {allure} from 'jest-allure2-reporter/api';
test.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])('sum(a, b) = (a + b)', (a, b, expected) => {
allure.parameters({a, b, expected});
});
jest-allure2-reporter also supports attaching individual parameters, where you can also customize their options, e.g.:
allure.parameter('expected', expected, { mode: 'hidden' });
The options parameter is an object of type Parameter:
export interface Parameter {
name: string;
value: string;
excluded?: boolean;
mode?: "hidden" | "masked" | "default";
}
The options allow you to fine-tune the way your parameters are displayed in the report:
excluded: true- exclude the parameter from allure-results (sensitive or unnecessary verbose data)mode: "masked"- mask the parameter value with******in the generated reportmode: "hidden"- exclude the parameter from the generated report completely
The allure.parameter API can be used also on the top level, e.g.:
import {allure} from 'jest-allure2-reporter/api';
describe('Login Screen (New)', () => {
allure.parameter('featureToggles', { 'com.ShowNewLogin': 'true' });
// ...
});
describe('Login Screen (Legacy)', () => {
allure.parameter('featureToggles', { 'com.ShowNewLogin': 'false' });
// ...
});