diff options
author | 2023-02-03 17:04:47 -0800 | |
---|---|---|
committer | 2023-02-03 17:04:47 -0800 | |
commit | 4590e2b83acbab63f1516c795f7f79a22f5d3083 (patch) | |
tree | 48a67bc6292e52d7979c3d7449ef03105b605ca3 /test | |
parent | 2758e0cab9286acbb14a6b4f6d367f078a7a7350 (diff) | |
download | bun-4590e2b83acbab63f1516c795f7f79a22f5d3083.tar.gz bun-4590e2b83acbab63f1516c795f7f79a22f5d3083.tar.zst bun-4590e2b83acbab63f1516c795f7f79a22f5d3083.zip |
Add test for propagating exception
Diffstat (limited to 'test')
-rw-r--r-- | test/bun.js/setTimeout.test.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/bun.js/setTimeout.test.js b/test/bun.js/setTimeout.test.js index 2670f8519..52430bd03 100644 --- a/test/bun.js/setTimeout.test.js +++ b/test/bun.js/setTimeout.test.js @@ -104,3 +104,26 @@ it("Bun.sleep", async () => { expect(sleeps).toBe(3); }); + +it("Bun.sleep propagates exceptions", async () => { + try { + await Bun.sleep(1).then(a => { + throw new Error("TestPassed"); + }); + throw "Should not reach here"; + } catch (err) { + expect(err.message).toBe("TestPassed"); + } +}); + +it("node.js timers/promises setTimeout propagates exceptions", async () => { + const { setTimeout } = require("timers/promises"); + try { + await setTimeout(1).then(a => { + throw new Error("TestPassed"); + }); + throw "Should not reach here"; + } catch (err) { + expect(err.message).toBe("TestPassed"); + } +}); |