aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/setTimeout.test.js23
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");
+ }
+});