Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 810e726

Browse files
committed
Add new test for error handling
1 parent 614c309 commit 810e726

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

index.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,18 @@ describe("Tests", () => {
110110
await Promise.all(promises)
111111
assert.deepEqual<number[]>(data, [500, 1000, 1500, 2000], "Data is [500, 1000, 1500, 2000]")
112112
})
113+
it("Worker queue with error handling", async function () {
114+
const queue = new ConcurrentPriorityWorkerQueue({
115+
worker: async function () {
116+
throw new Error("Test error")
117+
},
118+
})
119+
let caughtError = false;
120+
try {
121+
await queue.enqueue(1000, 0)
122+
} catch (e) {
123+
caughtError = true;
124+
}
125+
assert.isTrue(caughtError, "Caught error successfully")
126+
})
113127
})

0 commit comments

Comments
 (0)