I'm using mocha for testing, when I code below, the test will get timeout:
describe("myTest", () => {
it("myTest-0", async () => {
await new Promise(async (res, rej) => {
throw new Error("this is error");
});
});
});
=========================================================
but if I remove new Promise executor's async
prefix, the test will throw error immediately:
describe("myTest", () => {
it("myTest-0", () => {
await new Promise(async (res, rej) => {
throw new Error("this is error");
});
});
});
=========================================
why the first one get timeout instead of throwing error immediately?