* Options consumed by innerFail to construct and throw the AssertionError. * @typedef {object} InnerFailOptions * @property {any} actual Actual value * @property {any} expected Expected value * @property {MessageTuple} message Message * @property {string} operator Operator * @property {Functio
(fn)
| 77 | */ |
| 78 | |
| 79 | function getErrMessage(fn) { |
| 80 | const tmpLimit = Error.stackTraceLimit; |
| 81 | const errorStackTraceLimitIsWritable = isErrorStackTraceLimitWritable(); |
| 82 | // Make sure the limit is set to 1. Otherwise it could fail (<= 0) or it |
| 83 | // does to much work. |
| 84 | if (errorStackTraceLimitIsWritable) Error.stackTraceLimit = 1; |
| 85 | // We only need the stack trace. To minimize the overhead use an object |
| 86 | // instead of an error. |
| 87 | const err = {}; |
| 88 | ErrorCaptureStackTrace(err, fn); |
| 89 | if (errorStackTraceLimitIsWritable) Error.stackTraceLimit = tmpLimit; |
| 90 | |
| 91 | let source = getErrorSourceExpression(err); |
| 92 | if (source) { |
| 93 | source = StringPrototypeReplace(source, escapeSequencesRegExp, escapeFn); |
| 94 | return `The expression evaluated to a falsy value:\n\n ${source}\n`; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * @param {InnerFailOptions} obj |
no test coverage detected
searching dependent graphs…