Node.js assert.throws with async functions (Promises)
问题 I want to check if an async function throws using assert.throws from the native assert module. I tried with const test = async () => await aPromise(); assert.throws(test); // AssertionError: Missing expected exception.. It (obvioulsy?) doesn't work because the function exits before the Promise is resolved. Yet I found this question where the same things is attained using callbacks. Any suggestion? (I'm transpiling to Node.js native generators using Babel) 回答1: node 10 and newer Since Node.js