diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 5af6e7bd8a..6dd18a64ee 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -230,7 +230,7 @@ var generateDiff = (exports.generateDiff = function (actual, expected) { * @return {{ message: string, msg: string, stack: string }} */ var getFullErrorStack = function (err, seen) { - if (seen && seen.has(err)) { + if (seen?.has(err)) { return { message: '', msg: '', stack: '' }; } diff --git a/lib/runner.js b/lib/runner.js index 60a19f0e3f..87b4b8c3a4 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -448,7 +448,7 @@ Runner.prototype.fail = function (test, err, force) { const alreadyFiltered = new Set(); let currentErr = err; - while (currentErr && currentErr.stack && !alreadyFiltered.has(currentErr)) { + while (currentErr?.stack && !alreadyFiltered.has(currentErr)) { alreadyFiltered.add(currentErr); try {