I have a block of code similar to the following, which contains a function utilizing async
. Whenever I insert an assert statement within this function, it causes the code execution to halt at that specific line without throwing any errors. It simply stops in its tracks.
async function testMongo() {
let db = await dbConnect();
await db.collection("stories").remove({});
let c = await count("stories", {} );
assert.strictEqual(c, 999); // should fail
console.log("moving on..."); /// will never get reached.
}
I am perplexed as to why the assertion might be disappearing. This issue reminds me of previous instances where errors got lost within event emitters. It appears that the immediate return of the async function behaves akin to some sort of event emitter or Promise.