jest-circus-allure-environment
jest-circus-allure-environment copied to clipboard
No stacktrace in error message
Describe the bug
We just show error messages, but somehow we ignored the stacktrace which increased the investigation time
I would suggest to update handleError
function
handleError(error) {
var _a;
if (Array.isArray(error)) {
// Test_done event sends an array of arrays containing errors.
error = _.flattenDeep(error)[0];
}
let status = allure_js_commons_1.Status.BROKEN;
let message = error.name;
let trace = error.stack || error.message; // I changed here
if (error.matcherResult) {
status = allure_js_commons_1.Status.FAILED;
const matcherMessage = typeof error.matcherResult.message === 'function' ? error.matcherResult.message() : error.matcherResult.message;
const [line1, line2, ...restOfMessage] = matcherMessage.split('\n');
message = [line1, line2].join('\n');
trace = error.stack || restOfMessage.join('\n'); // I changed here
}
if (!message && trace) {
message = trace;
trace = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.replace(message, 'No stack trace provided');
}
if (trace === null || trace === void 0 ? void 0 : trace.includes(message)) {
trace = trace === null || trace === void 0 ? void 0 : trace.replace(message, '');
}
if (!message) {
message = 'Error. Expand for more details.';
trace = error;
}
return {
status,
message: stripAnsi(message),
trace: stripAnsi(trace)
};
}