The code below should actually catch the error thrown by the async function but, it is showing resolved of then block.
const {
forEach
} = require("lodash");
async function test(num) {
await (async() =>
setTimeout(() => {
if (num == 11) {
throw 'err';
}
}, 1000))();
return num;
}
test(11).then(() =>
console.log("Resolved")
).catch(() =>
console.log("Rejected")
);