Statuses
Jest Allure 2 Reporter supports all the standard statuses defined by the Allure Framework.
It provides a clear indication whether your test cases have passed
, failed
, were broken
,
skipped
, or whether their status is unknown
.
π’ Passedβ
Status passed
is reported when the test case has passed successfully:
test('passed test', () => {
expect(2 + 2).toBe(4);
});
π΄ Failedβ
Status failed
is reported when the test case has revealed a product defect, or it has invalid assertions:
test('failed test', () => {
expect(2 + 2).not.toBe(4);
});
You can build a custom defects classification system based on test status, error messages, and stack traces.
π‘ Brokenβ
Status broken
is reported when the test case has failed due to an error in the test code:
test('broken test', () => {
const user = null;
// TypeError: Cannot read property 'name' of null
expect(user.name).toBe('John');
});
If your test assertions throw errors directly instead of using or extending
Jest's expect
API, they will be reported as β π‘Β Broken tests by default.
To report them as π΄Β Failed tests, you can use a status
customizer function:
module.exports = {
// ...
reporters: [
// ...
['jest-allure2-reporter', {
testCase: {
status: ({ value }) => value === 'broken' ? 'failed' : value,
},
}],
],
};
βͺ Skippedβ
Status skipped
is reported when the test case has been skipped due to a test.skip
or test.todo
call:
test.skip('skipped test', () => {
expect(2 + 2).toBe(4);
});
test.todo('todo test');
There's no way to distinguish between test.skip
and test.todo
calls, so both will be reported as skipped.
π£ Unknownβ
Status unknown
is reported when information about the test case result has been lost or not created:
test('unknown test', () => {
process.exit(0); // the test information will be unrecoverable
});
In the real world scenarios, this might happen if you use --bail
in Jest with
multiple test suites running in parallel, and one of them fails. In this case,
Jest will exit immediately, and the reporter will not be able to wait for the
test results from the other workers.