All files / wdio-allure-reporter/src compoundError.js

100% Statements 8/8
100% Branches 2/2
100% Functions 4/4
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  86x                 9x   18x 4x     9x 9x      
function indentAll(lines) {
    return lines.split('\n').map(x => '    ' + x).join('\n')
}
 
/**
 * An error that encapsulates more than one error, to support soft-assertions from Jasmine
 * even though Allure's API assumes one error-per test
 */
export default class CompoundError extends Error {
    constructor(...innerErrors) {
        const message = ['CompoundError: One or more errors occurred. ---'].
            concat(innerErrors.map(x => {
                if (x.stack) return `${indentAll(x.stack)}\n--- End of stack trace ---`
                else return `   ${x.message}\n--- End of error message ---`
            })).join('\n')
 
        super(message)
        this.innerErrors = innerErrors
    }
}